diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-31 13:04:22 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-31 13:04:22 +0000 |
commit | 01bba060c1c2ba34596d2b3b6b2dbead70d00ab0 (patch) | |
tree | 8a3dc03eccf3fd354185bedefce05c9cc4755c71 /usr.sbin/bgpd | |
parent | fcfa21fc1c6eea52d2bb27de4fa8cd43b210a224 (diff) |
Replace another strtol() with strtonum() making the error checking easier
to understand. This is modeled after bgpctl's parse_prefix function.
OK henning@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/config.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c index 1464491e42b..fd87cbfe4fe 100644 --- a/usr.sbin/bgpd/config.c +++ b/usr.sbin/bgpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.48 2006/03/15 11:33:42 claudio Exp $ */ +/* $OpenBSD: config.c,v 1.49 2007/01/31 13:04:21 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -181,13 +181,13 @@ host(const char *s, struct bgpd_addr *h, u_int8_t *len) { int done = 0; int mask; - char *p, *q, *ps; + char *p, *ps; + const char *errstr; if ((p = strrchr(s, '/')) != NULL) { - errno = 0; - mask = strtol(p+1, &q, 0); - if (errno == ERANGE || !q || *q || mask > 128 || q == (p+1)) { - log_warnx("invalid netmask"); + mask = strtonum(p + 1, 0, 128, &errstr); + if (errstr) { + log_warnx("prefixlen is %s: %s", errstr, p + 1); return (0); } if ((ps = malloc(strlen(s) - strlen(p) + 1)) == NULL) |