Skip to content

Commit 6fd5ae6

Browse files
SciresMWinterMute
authored andcommitted
generate correct save_data_owner_ids
1 parent 87f4744 commit 6fd5ae6

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/npdmtool.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,18 +466,33 @@ int CreateNpdm(const char *json, void **dst, u32 *dst_size) {
466466
sdois = cJSON_GetObjectItemCaseSensitive(fsaccess, "save_data_owner_ids");
467467
if (cJSON_IsArray(sdois)) {
468468
u32 *count = (u32 *)((u8 *)fah + fah->SdoiOffset);
469-
u64 *id = (u64 *)((u8 *)count + sizeof(u32));
470469
cJSON_ArrayForEach(sdoi, sdois) {
471-
if (!cJSON_GetU64FromObjectValue(sdoi, id)) {
470+
if (!cJSON_IsObject(sdoi)) {
472471
status = 0;
473472
goto NPDM_BUILD_END;
474473
}
475-
++id;
476474
++(*count);
477475
}
478476

477+
u8 *accessibility = (u8 *)count + sizeof(u32);
478+
u64 *id = (u64 *)(accessibility + (((*count) + 3ULL) & ~3ULL));
479+
480+
cJSON_ArrayForEach(sdoi, sdois) {
481+
if (!cJSON_GetU8(sdoi, "accessibility", accessibility)) {
482+
status = 0;
483+
goto NPDM_BUILD_END;
484+
}
485+
if (!cJSON_GetU64(sdoi, "id", id)) {
486+
status = 0;
487+
goto NPDM_BUILD_END;
488+
}
489+
490+
++accessibility;
491+
++id;
492+
}
493+
479494
if (*count > 0) {
480-
fah->SdoiSize = sizeof(u32) + sizeof(u64) * (*count);
495+
fah->SdoiSize = sizeof(u32) + sizeof(u8) * ((((*count) + 3ULL) & ~3ULL)) + sizeof(u64) * (*count);
481496
}
482497
}
483498

0 commit comments

Comments
 (0)