From af75cfaa93b1ac933bb8b5ecec64fcc0c269a013 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Tue, 26 Feb 2008 16:15:18 -0800 Subject: fix for bug 2868: return failure for invalid values. --- src/cli_new.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cli_new.c b/src/cli_new.c index 353babd..1ecbe83 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -745,11 +745,12 @@ int char2val(vtw_def *def, char *value, valstruct *valp) if (!token) return 0; if (token != EOL) { + fprintf(out_stream, "\"%s\" is not a valid value\n", value); print_msg("Badly formed value in %s\n", m_path.path + m_path.print_offset); if (token == VALUE) my_free(get_cli_value_ptr()->val); - return 0; + return -1; } } return 0; -- cgit v1.2.3 From d777950023130447aaafa67df6bea41f67bcf8e0 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Tue, 26 Feb 2008 18:12:29 -0800 Subject: fix for bug 2749: add u32 range check --- src/check_tmpl.c | 3 +++ src/cli_val.l | 12 ++++++++++++ 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/check_tmpl.c b/src/check_tmpl.c index 8be1a7f..cbb9aa1 100644 --- a/src/check_tmpl.c +++ b/src/check_tmpl.c @@ -1,5 +1,8 @@ +#define _ISOC99_SOURCE #include #include +#include +#include #include "cli_val.h" diff --git a/src/cli_val.l b/src/cli_val.l index 5856cea..c24a6dc 100644 --- a/src/cli_val.l +++ b/src/cli_val.l @@ -1,4 +1,7 @@ %{ +#define __USE_ISOC99 +#include + #include "cli_val.h" #include "cli_parse.h" #include "cli_objects.h" @@ -226,6 +229,15 @@ false { } [0-9]+ { + long long int cval = 0; + char *endp = NULL; + errno = 0; + cval = strtoll(yytext, &endp, 10); + if ((errno == ERANGE && (cval == LLONG_MAX || cval == LLONG_MIN)) + || (errno != 0 && cval == 0) + || (*endp != '\0') || (cval < 0) || (cval > UINT_MAX)) { + return SYNTAX_ERROR; + } make_val_value(INT_TYPE); return VALUE; } -- cgit v1.2.3