- do not use strtol for parsing critical values that can get large.

This function will truncate everything that is larger than LONG_MAX or smaller than LONG_MIN to fit into a long variable, but longs are 32 bit on Windows and 64 bit elsewhere, so to ensure consistency and the ability to parse larger values better use strtoll which does not truncate 32 bit values.
This commit is contained in:
Christoph Oelckers 2017-02-01 11:19:55 +01:00
commit 6d28aa3541
20 changed files with 47 additions and 35 deletions

View file

@ -103,7 +103,7 @@ loop:
c = *sourcep++;
if (c == 'x' || c == 'X')
{
yylval->val = (int)strtol(sourcep, &sourcep, 16);
yylval->val = (int)strtoll(sourcep, &sourcep, 16);
return TokenTrans[NUM];
}
else
@ -114,7 +114,7 @@ loop:
char *endp;
sourcep--;
yylval->val = (int)strtol(sourcep, &endp, 10);
yylval->val = (int)strtoll(sourcep, &endp, 10);
if (*endp == '.')
{
// It's a float