summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2001-07-18 01:08:44 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2001-07-18 01:08:44 +0000
commitcacab61b7f2531c3cef1842e1bb4937095842572 (patch)
tree651400335e816a8978065d09f91f2d8462908a60
parent92fe35363b92bab72e0c3645de028e642426c678 (diff)
check number range to fit in 32 bits
-rw-r--r--sbin/pfctl/parse.y11
1 files changed, 7 insertions, 4 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 4cb687c3084..1de55beaaeb 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.11 2001/07/18 00:41:48 mickey Exp $ */
+/* $OpenBSD: parse.y,v 1.12 2001/07/18 01:08:43 mickey Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -685,13 +685,16 @@ yylex(void)
if (isdigit(c)) {
yylval.number = 0;
do {
- yylval.number *= 10;
- yylval.number += c - '0';
+ u_int64_t n = (u_int64_t)yylval.number * 10 + c - '0';
+ if (n > 0xffffffff)
+ errx(1, "line %d: number is too large",
+ lineno);
+ yylval.number = (u_int32_t)n;
} while ((c = getc(fin)) != EOF && isdigit(c));
ungetc(c, fin);
if (debug > 1)
fprintf(stderr, "number: %d\n", yylval.number);
- return NUMBER;
+ return (NUMBER);
}
#define allowed_in_string(x) \