mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Add safeguards against string overflows
Use snprintf instead of other unsafe functions. That way it is possible to limit the size of the buffer and to ensure that it never overflows. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -347,7 +347,7 @@ void fstk_RunMacroArg(int32_t s)
|
||||
|
||||
pushcontext();
|
||||
nCurrentStatus = STAT_isMacroArg;
|
||||
sprintf(tzCurrentFileName, "%c", (uint8_t)s);
|
||||
snprintf(tzCurrentFileName, _MAX_PATH + 1, "%c", (uint8_t)s);
|
||||
CurrentFlexHandle = yy_scan_bytes(sym, strlen(sym));
|
||||
yy_switch_to_buffer(CurrentFlexHandle);
|
||||
}
|
||||
@@ -410,7 +410,7 @@ void fstk_Init(char *s)
|
||||
|
||||
nMacroCount = 0;
|
||||
nCurrentStatus = STAT_isInclude;
|
||||
strcpy(tzCurrentFileName, tzFileName);
|
||||
snprintf(tzCurrentFileName, _MAX_PATH + 1, "%s", tzFileName);
|
||||
CurrentFlexHandle = yy_create_buffer(pCurrentFile);
|
||||
yy_switch_to_buffer(CurrentFlexHandle);
|
||||
nLineNo = 1;
|
||||
|
||||
Reference in New Issue
Block a user