summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-04-25 21:38:23 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-04-25 21:38:23 +0000
commit014bf114c9394ae93fecb41a06c8304fd367356d (patch)
treea6bec913539ca9940f6b1aa01c5825f1d82541e1 /lib
parent99f2c1afbd977dfb2f1ee7c57932c6430dae32d2 (diff)
Cut the aliases part of /etc/rpc lines before feeding them to strtonum(), for
it will fail otherwise; ok deraadt@ millert@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/rpc/getrpcent.c13
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++;