summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2010-04-20 11:03:06 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2010-04-20 11:03:06 +0000
commit917b779947fd65884b2ae709d7cf37fdb773f1a3 (patch)
tree02792ca31bab5caee2b4004c3dfda27c6e316dc3
parentfbf276b9c9db3385d53b0a4985e7369632824758 (diff)
when a size is declared with a quantifier in smtpd.conf, have parse.y use
scan_scaled(3) to support the quantifiers rather than rolling my own code. prompted by jacekm@
-rw-r--r--usr.sbin/smtpd/parse.y24
1 files changed, 9 insertions, 15 deletions
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index 9074220a3d6..f7c5469f1bd 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.53 2010/04/19 14:37:33 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.54 2010/04/20 11:03:05 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -47,6 +47,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <util.h>
#include "smtpd.h"
@@ -198,23 +199,16 @@ size : NUMBER {
}
$$ = $1;
}
- | NUMBER STRING {
- if ($1 < 0) {
- yyerror("invalid size: %lld", $1);
- YYERROR;
- }
+ | STRING {
+ long long result;
- if (strcmp("KB", $2) == 0)
- $$ = 1024;
- else if (strcmp("MB", $2) == 0)
- $$ = 1048576;
- else if (strcmp("GB", $2) == 0)
- $$ = 1073741824;
- else {
- yyerror("invalid quantifier: %s", $2);
+ if (scan_scaled($1, &result) == -1 || result < 0) {
+ yyerror("invalid size: %s", $1);
YYERROR;
}
- $$ *= $1;
+ free($1);
+
+ $$ = result;
}
;