提交 06650b96 编写于 作者: R Rich Felker

fix getservby*() with null pointer for protocol argument

not sure this is the best fix but it should work
上级 7be3b5a0
...@@ -12,6 +12,10 @@ int getservbyname_r(const char *name, const char *prots, ...@@ -12,6 +12,10 @@ int getservbyname_r(const char *name, const char *prots,
struct addrinfo *ai, hint = { .ai_family = AF_INET }; struct addrinfo *ai, hint = { .ai_family = AF_INET };
int i; int i;
if (!prots) return -(
getservbyname_r(name, "tcp", se, buf, buflen, res)
&& getservbyname_r(name, "udp", se, buf, buflen, res) );
/* Align buffer */ /* Align buffer */
i = (uintptr_t)buf & sizeof(char *)-1; i = (uintptr_t)buf & sizeof(char *)-1;
if (!i) i = sizeof(char *); if (!i) i = sizeof(char *);
......
...@@ -15,6 +15,10 @@ int getservbyport_r(int port, const char *prots, ...@@ -15,6 +15,10 @@ int getservbyport_r(int port, const char *prots,
.sin_port = port, .sin_port = port,
}; };
if (!prots) return -(
getservbyport_r(port, "tcp", se, buf, buflen, res)
&& getservbyport_r(port, "udp", se, buf, buflen, res) );
/* Align buffer */ /* Align buffer */
i = (uintptr_t)buf & sizeof(char *)-1; i = (uintptr_t)buf & sizeof(char *)-1;
if (!i) i = sizeof(char *); if (!i) i = sizeof(char *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册