diff --git a/src/elf2kip.c b/src/elf2kip.c index 6bf852d..005957c 100644 --- a/src/elf2kip.c +++ b/src/elf2kip.c @@ -341,13 +341,17 @@ int ParseKipConfiguration(const char *json, KipHeader *kip_hdr) { status = 0; goto PARSE_CAPS_END; } + + u8 real_highest_prio = (lowest_prio < highest_prio) ? lowest_prio : highest_prio; + u8 real_lowest_prio = (lowest_prio > highest_prio) ? lowest_prio : highest_prio; + desc = highest_cpu; desc <<= 8; desc |= lowest_cpu; desc <<= 6; - desc |= (lowest_prio & 0x3F); + desc |= (real_highest_prio & 0x3F); desc <<= 6; - desc |= (highest_prio & 0x3F); + desc |= (real_lowest_prio & 0x3F); kip_hdr->Capabilities[cur_cap++] = (u32)((desc << 4) | (0x0007)); } else if (!strcmp(type_str, "syscalls")) { if (!cJSON_IsObject(value)) { diff --git a/src/npdmtool.c b/src/npdmtool.c index 1de8b77..0481b2d 100644 --- a/src/npdmtool.c +++ b/src/npdmtool.c @@ -646,13 +646,17 @@ int CreateNpdm(const char *json, void **dst, u32 *dst_size) { status = 0; goto NPDM_BUILD_END; } + + u8 real_highest_prio = (lowest_prio < highest_prio) ? lowest_prio : highest_prio; + u8 real_lowest_prio = (lowest_prio > highest_prio) ? lowest_prio : highest_prio; + desc = highest_cpu; desc <<= 8; desc |= lowest_cpu; desc <<= 6; - desc |= (lowest_prio & 0x3F); + desc |= (real_highest_prio & 0x3F); desc <<= 6; - desc |= (highest_prio & 0x3F); + desc |= (real_lowest_prio & 0x3F); caps[cur_cap++] = (u32)((desc << 4) | (0x0007)); } else if (!strcmp(type_str, "syscalls")) { if (!cJSON_IsObject(value)) {