diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-08-01 18:36:30 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-08-01 18:36:30 +0000 |
| commit | e648e61a747c6c13ccea7d97066dfb07d4461d96 (patch) | |
| tree | 69b027a83a6c1bbd41e1a5844a524a2b14c4bb22 /lib/command_parse.y | |
| parent | 1a8c390d4abc7c3f599813ddee6ca3990de7576c (diff) | |
lib: Fix OOB range parses, variable matches
Variables now allow strings beginning with numbers
to match, ranges and numbers are now long long to
fix OOB parses resulting in integer wraparounds.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command_parse.y')
| -rw-r--r-- | lib/command_parse.y | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/command_parse.y b/lib/command_parse.y index 01fc01d302..146c8b6101 100644 --- a/lib/command_parse.y +++ b/lib/command_parse.y @@ -30,7 +30,7 @@ extern void yyerror(const char *); /* valid types for tokens */ %union{ - int integer; + signed long long integer; char *string; struct graph_node *node; } @@ -91,7 +91,7 @@ start: sentence_root yyerror("Duplicate command."); YYABORT; } - fprintf(stderr, "Added END_GN with active children: %d\n", vector_active(end->children)); + fprintf(stderr, "Parsed full command successfully.\n"); } sentence_root: WORD @@ -179,8 +179,9 @@ placeholder_token: // get the numbers out strsep(&yylval.string, "(-)"); - $$->min = atoi( strsep(&yylval.string, "(-)") ); - $$->max = atoi( strsep(&yylval.string, "(-)") ); + char *endptr; + $$->min = strtoll( strsep(&yylval.string, "(-)"), &endptr, 10 ); + $$->max = strtoll( strsep(&yylval.string, "(-)"), &endptr, 10 ); free ($1); } @@ -313,7 +314,7 @@ void yyerror(char const *message) { fprintf(stderr, "Token on error: "); if (yylval.string) fprintf(stderr, "%s\n", yylval.string); else if (yylval.node) fprintf(stderr, "%s\n", yylval.node->text); - else fprintf(stderr, "%d\n", yylval.integer); + else fprintf(stderr, "%lld\n", yylval.integer); } |
