diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-07-14 20:16:23 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-07-14 20:16:23 -0400 |
commit | 06650b968461b72d5eb44063dd68c176be330372 (patch) | |
tree | cb3bb5ea46b47d8cd87dbb730caa4711a815859e /src/network | |
parent | 7be3b5a073e77f1147acfa728725f9f81d20ceb0 (diff) | |
download | musl-06650b968461b72d5eb44063dd68c176be330372.tar.gz musl-06650b968461b72d5eb44063dd68c176be330372.tar.bz2 musl-06650b968461b72d5eb44063dd68c176be330372.tar.xz musl-06650b968461b72d5eb44063dd68c176be330372.zip |
fix getservby*() with null pointer for protocol argument
not sure this is the best fix but it should work
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/getservbyname_r.c | 4 | ||||
-rw-r--r-- | src/network/getservbyport_r.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/network/getservbyname_r.c b/src/network/getservbyname_r.c index 5c025150..efa5d910 100644 --- a/src/network/getservbyname_r.c +++ b/src/network/getservbyname_r.c @@ -12,6 +12,10 @@ int getservbyname_r(const char *name, const char *prots, struct addrinfo *ai, hint = { .ai_family = AF_INET }; int i; + if (!prots) return -( + getservbyname_r(name, "tcp", se, buf, buflen, res) + && getservbyname_r(name, "udp", se, buf, buflen, res) ); + /* Align buffer */ i = (uintptr_t)buf & sizeof(char *)-1; if (!i) i = sizeof(char *); diff --git a/src/network/getservbyport_r.c b/src/network/getservbyport_r.c index f119abc8..821afae9 100644 --- a/src/network/getservbyport_r.c +++ b/src/network/getservbyport_r.c @@ -15,6 +15,10 @@ int getservbyport_r(int port, const char *prots, .sin_port = port, }; + if (!prots) return -( + getservbyport_r(port, "tcp", se, buf, buflen, res) + && getservbyport_r(port, "udp", se, buf, buflen, res) ); + /* Align buffer */ i = (uintptr_t)buf & sizeof(char *)-1; if (!i) i = sizeof(char *); |