summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getproto.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2004-10-25 03:09:01 +0000
committermillert <millert@openbsd.org>2004-10-25 03:09:01 +0000
commite3a1e9bf34eea155696e6eec761a1bf8eceb7daa (patch)
treee76d39ea6eed374cd8878ce3f6e3544b6a4c9806 /lib/libc/net/getproto.c
parentregen (diff)
downloadwireguard-openbsd-e3a1e9bf34eea155696e6eec761a1bf8eceb7daa.tar.xz
wireguard-openbsd-e3a1e9bf34eea155696e6eec761a1bf8eceb7daa.zip
Change return value of reentrant getproto* and getserv* to match the
IBM/Digital API.
Diffstat (limited to 'lib/libc/net/getproto.c')
-rw-r--r--lib/libc/net/getproto.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/libc/net/getproto.c b/lib/libc/net/getproto.c
index 3f05a93cce6..16d840394ce 100644
--- a/lib/libc/net/getproto.c
+++ b/lib/libc/net/getproto.c
@@ -28,26 +28,26 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getproto.c,v 1.5 2004/10/17 20:24:23 millert Exp $";
+static char rcsid[] = "$OpenBSD: getproto.c,v 1.6 2004/10/25 03:09:01 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <netdb.h>
#include <stdio.h>
-struct protoent *
+int
getprotobynumber_r(int num, struct protoent *pe, struct protoent_data *pd)
{
- struct protoent *p;
+ int error;
setprotoent_r(pd->stayopen, pd);
- while ((p = getprotoent_r(pe, pd)))
- if (p->p_proto == num)
+ while ((error = getprotoent_r(pe, pd)) == 0)
+ if (pe->p_proto == num)
break;
if (!pd->stayopen && pd->fp != NULL) {
(void)fclose(pd->fp);
pd->fp = NULL;
}
- return (p);
+ return (error);
}
struct protoent *
@@ -56,5 +56,7 @@ getprotobynumber(int num)
extern struct protoent_data _protoent_data;
static struct protoent proto;
- return getprotobynumber_r(num, &proto, &_protoent_data);
+ if (getprotobynumber_r(num, &proto, &_protoent_data) != 0)
+ return (NULL);
+ return (&proto);
}