diff options
author | 2015-04-25 21:38:22 +0000 | |
---|---|---|
committer | 2015-04-25 21:38:22 +0000 | |
commit | 97a365884558829f4c72cf5b13c999fb82514598 (patch) | |
tree | 5befb3ce54a7dba13282a72423f0d178a7f57c01 | |
parent | We now following the ABI and always clear cld on function entry, so remove (diff) | |
download | wireguard-openbsd-97a365884558829f4c72cf5b13c999fb82514598.tar.xz wireguard-openbsd-97a365884558829f4c72cf5b13c999fb82514598.zip |
Cut the aliases part of /etc/rpc lines before feeding them to strtonum(), for
it will fail otherwise; ok deraadt@ millert@
-rw-r--r-- | lib/libc/rpc/getrpcent.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/libc/rpc/getrpcent.c b/lib/libc/rpc/getrpcent.c index 75df6a8cfb9..76b8e89a91c 100644 --- a/lib/libc/rpc/getrpcent.c +++ b/lib/libc/rpc/getrpcent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getrpcent.c,v 1.17 2015/04/18 18:28:37 deraadt Exp $ */ +/* $OpenBSD: getrpcent.c,v 1.18 2015/04/25 21:38:22 miod Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -151,7 +151,7 @@ interpret(char *val, int len) const char *errstr; struct rpcdata *d = _rpcdata(); char *p; - char *cp, **q; + char *cp, *num, **q; if (d == NULL) return (0); @@ -172,13 +172,14 @@ interpret(char *val, int len) d->rpc.r_name = d->line; while (*cp == ' ' || *cp == '\t') cp++; - d->rpc.r_number = strtonum(cp, 0, INT_MAX, &errstr); + num = cp; + cp = strpbrk(cp, " \t"); + if (cp != NULL) + *cp++ = '\0'; + d->rpc.r_number = strtonum(num, 0, INT_MAX, &errstr); if (errstr) return (0); q = d->rpc.r_aliases = d->rpc_aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; |