diff --git a/main.cpp b/main.cpp index 72bd94b..3b8684f 100644 --- a/main.cpp +++ b/main.cpp @@ -1488,12 +1488,17 @@ static bool saveEntry(FILE* outFile, char* path, rk_entry_type type, } static inline uint32_t convertChipType(const char* chip) { - char buffer[5]; - memset(buffer, 0, sizeof(buffer)); - snprintf(buffer, sizeof(buffer), "%s", chip); - return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3]; + if (strlen(chip) > 4) { + return 0; + } + + char buffer[5]; + memset(buffer, 0, sizeof(buffer)); + snprintf(buffer, sizeof(buffer), "%s", chip); + return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3]; } + static inline uint32_t getChipType(const char* chip) { printf("chip: %s\n", chip); int chipType = RKNONE_DEVICE;