Skip to content

Commit f0807d2

Browse files
authored
Change sanitization check for ExportDataAsCode (#3837)
* Change sanitization check for `ExportDataAsCode` I opted to use `isalnum` function since it should handle most cases. It cannot however handle cases of files beginning with numbers. * Update `ExportDataAsCode` condition * Reinsert comment on `ExportDataAsCode`
1 parent 074fbb0 commit f0807d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ bool ExportDataAsCode(const unsigned char *data, int dataSize, const char *fileN
320320
{
321321
// Convert variable name to uppercase
322322
if ((varFileName[i] >= 'a') && (varFileName[i] <= 'z')) { varFileName[i] = varFileName[i] - 32; }
323-
// Replace '-' (non valid character for C identifier with '_')
324-
if (varFileName[i] == '-') { varFileName[i] = '_'; }
323+
// Replace non valid character for C identifier with '_'
324+
else if (varFileName[i] == '.' || varFileName[i] == '-' || varFileName[i] == '?' || varFileName[i] == '!' || varFileName[i] == '+') { varFileName[i] = '_'; }
325325
}
326326

327327
byteCount += sprintf(txtData + byteCount, "#define %s_DATA_SIZE %i\n\n", varFileName, dataSize);

0 commit comments

Comments
 (0)