mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 21:52:48 +00:00
fix buffer overflow
This would cause exceptions when encrypting/decrypting CIA files to `0:/gm9/out`.
This commit is contained in:
parent
9514755989
commit
64414e12ab
@ -1317,12 +1317,18 @@ u32 CryptCiaFile(const char* orig, const char* dest, u16 crypto) {
|
|||||||
|
|
||||||
// if not inplace: take over CIA metadata
|
// if not inplace: take over CIA metadata
|
||||||
if (!inplace && (info.size_meta == CIA_META_SIZE)) {
|
if (!inplace && (info.size_meta == CIA_META_SIZE)) {
|
||||||
CiaMeta* meta = (CiaMeta*) (void*) (cia + 1);
|
CiaMeta* meta = (CiaMeta*) malloc(sizeof(CiaMeta));
|
||||||
if ((fvx_qread(orig, meta, info.offset_meta, CIA_META_SIZE, NULL) != FR_OK) ||
|
if (!meta) {
|
||||||
(fvx_qwrite(dest, meta, info.offset_meta, CIA_META_SIZE, NULL) != FR_OK)) {
|
|
||||||
free(cia);
|
free(cia);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if ((fvx_qread(orig, meta, info.offset_meta, CIA_META_SIZE, NULL) != FR_OK) ||
|
||||||
|
(fvx_qwrite(dest, meta, info.offset_meta, CIA_META_SIZE, NULL) != FR_OK)) {
|
||||||
|
free(cia);
|
||||||
|
free(meta);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
free(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix TMD hashes, write CIA stub to destination
|
// fix TMD hashes, write CIA stub to destination
|
||||||
|
Loading…
x
Reference in New Issue
Block a user