Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d1c15438
Commit
d1c15438
authored
Oct 18, 2008
by
Rob Shearman
Committed by
Alexandre Julliard
Oct 18, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc: Check for overflows when parsing integer constants.
parent
cb3ea684
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
parser.l
tools/wrc/parser.l
+17
-3
No files found.
tools/wrc/parser.l
View file @
d1c15438
...
@@ -103,6 +103,7 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
...
@@ -103,6 +103,7 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
#include <string.h>
#include <string.h>
#include <ctype.h>
#include <ctype.h>
#include <assert.h>
#include <assert.h>
#include <limits.h>
#ifndef HAVE_UNISTD_H
#ifndef HAVE_UNISTD_H
#define YY_NO_UNISTD_H
#define YY_NO_UNISTD_H
...
@@ -295,6 +296,19 @@ static struct keyword *iskeyword(char *kw)
...
@@ -295,6 +296,19 @@ static struct keyword *iskeyword(char *kw)
return kwp;
return kwp;
}
}
/* converts an integer in string form to an unsigned long and prints an error
* on overflow */
static unsigned long xstrtoul(const char *nptr, char **endptr, int base)
{
unsigned long l;
errno = 0;
l = strtoul(nptr, endptr, base);
if (l == ULONG_MAX && errno == ERANGE)
parser_error("integer constant %s is too large\n", nptr);
return l;
}
%}
%}
/*
/*
...
@@ -378,9 +392,9 @@ static struct keyword *iskeyword(char *kw)
...
@@ -378,9 +392,9 @@ static struct keyword *iskeyword(char *kw)
\{ return tBEGIN;
\{ return tBEGIN;
\} return tEND;
\} return tEND;
[0-9]+[lL]? { parser_lval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
[0-9]+[lL]? { parser_lval.num =
x
strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num =
x
strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { parser_lval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { parser_lval.num =
x
strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
/*
/*
* The next two rules scan identifiers and filenames.
* The next two rules scan identifiers and filenames.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment