summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ripd/parse.y
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2006-10-25 20:01:49 +0000
committerhenning <henning@openbsd.org>2006-10-25 20:01:49 +0000
commit2d937911064bf9f1ccb4428b4cbd4476b66590cf (patch)
tree1a099e06cdf0630e18dd12c26d16fab1a1a91029 /usr.sbin/ripd/parse.y
parentgeez, the anno 2004 bgpd debug shitz made it to ripd too (diff)
downloadwireguard-openbsd-2d937911064bf9f1ccb4428b4cbd4476b66590cf.tar.xz
wireguard-openbsd-2d937911064bf9f1ccb4428b4cbd4476b66590cf.zip
strtonum, Pierre-Yves Ritschard <pyr@spootnik.org>
Diffstat (limited to 'usr.sbin/ripd/parse.y')
-rw-r--r--usr.sbin/ripd/parse.y29
1 files changed, 7 insertions, 22 deletions
diff --git a/usr.sbin/ripd/parse.y b/usr.sbin/ripd/parse.y
index 1c311b00884..04da8b4cf51 100644
--- a/usr.sbin/ripd/parse.y
+++ b/usr.sbin/ripd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.3 2006/10/25 20:01:02 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.4 2006/10/25 20:01:49 henning Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -81,7 +81,6 @@ struct sym {
int symset(const char *, const char *, int);
char *symget(const char *);
-int atoul(char *, u_long *);
struct iface *conf_get_if(struct kif *);
typedef struct {
@@ -113,14 +112,16 @@ grammar : /* empty */
;
number : STRING {
- u_long ulval;
+ u_int32_t uval;
+ const char *errstr;
- if (atoul($1, &ulval) == -1) {
- yyerror("%s is not a number", $1);
+ uval = strtonum($1, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ yyerror("number %s is %s", $1, errstr);
free($1);
YYERROR;
} else
- $$ = ulval;
+ $$ = uval;
free($1);
}
;
@@ -708,22 +709,6 @@ symget(const char *nam)
return (NULL);
}
-int
-atoul(char *s, u_long *ulvalp)
-{
- u_long ulval;
- char *ep;
-
- errno = 0;
- ulval = strtoul(s, &ep, 0);
- if (s[0] == '\0' || *ep != '\0')
- return (-1);
- if (errno == ERANGE && ulval == ULONG_MAX)
- return (-1);
- *ulvalp = ulval;
- return (0);
-}
-
struct iface *
conf_get_if(struct kif *kif)
{