From 523e37ec95195d09d64c327f3e76e74e9848caf6 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Tue, 16 Mar 2021 11:28:13 +0000 Subject: [PATCH] Prevent segfault when accessing 'Explore' menu --- menu/menu_explore.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/menu/menu_explore.c b/menu/menu_explore.c index 43747f890a..fa28edeb0e 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -597,7 +597,22 @@ static explore_state_t *explore_build_list(void) key_str = key->val.string.buff; if (string_is_equal(key_str, "crc")) { - crc32 = swap_if_little32(*(uint32_t*)val->val.binary.buff); + switch (strlen(val->val.binary.buff)) + { + case 1: + crc32 = *(uint8_t*)val->val.binary.buff; + break; + case 2: + crc32 = swap_if_little16(*(uint16_t*)val->val.binary.buff); + break; + case 4: + crc32 = swap_if_little32(*(uint32_t*)val->val.binary.buff); + break; + default: + crc32 = 0; + break; + } + continue; } else if (string_is_equal(key_str, "name"))