this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1112 from ddelemeny/bugfix-popup-overflow

Fix popup buffer overflow with long filenames

authored by

Vadim Grigoruk and committed by
GitHub
3357c278 88e44dcb

+18 -3
+18 -3
src/studio.c
··· 1016 1016 static void showPopupMessage(const char* text) 1017 1017 { 1018 1018 impl.popup.counter = POPUP_DUR; 1019 - strcpy(impl.popup.message, text); 1019 + memset(impl.popup.message, '\0', sizeof impl.popup.message); 1020 + strncpy(impl.popup.message, text, sizeof(impl.popup.message) - 1); 1020 1021 } 1021 1022 1022 1023 static void exitConfirm(bool yes, void* data) ··· 1370 1371 1371 1372 if(rom == CART_SAVE_OK) 1372 1373 { 1373 - char buffer[TICNAME_MAX]; 1374 - snprintf(buffer, TICNAME_MAX, "%s SAVED :)", impl.console->romName); 1374 + char buffer[STUDIO_TEXT_BUFFER_WIDTH]; 1375 + char str_saved[] = " SAVED :)"; 1376 + 1377 + s32 name_len = strlen(impl.console->romName); 1378 + if (name_len + strlen(str_saved) > sizeof(buffer)){ 1379 + char subbuf[sizeof(buffer) - sizeof(str_saved) - 5]; 1380 + memset(subbuf, '\0', sizeof subbuf); 1381 + strncpy(subbuf, impl.console->romName, sizeof subbuf-1); 1382 + 1383 + snprintf(buffer, sizeof(buffer), "%s[...]%s", subbuf, str_saved); 1384 + } 1385 + else 1386 + { 1387 + snprintf(buffer, sizeof(buffer), "%s%s", impl.console->romName, str_saved); 1388 + } 1389 + 1375 1390 1376 1391 for(s32 i = 0; i < (s32)strlen(buffer); i++) 1377 1392 buffer[i] = toupper(buffer[i]);