提交 7b5beabc 编写于 作者: R Rich Felker

fix regression in inet_aton due to misinterpretation of __ipparse return

inet_aton returns a boolean success value, whereas __ipparse returns 0
on success and -1 on failure. also change the conditional in inet_addr
to be consistent with other uses of __ipparse where only negative
values are treated as failure.
上级 f9fb20b4
......@@ -6,6 +6,6 @@
in_addr_t inet_addr(const char *p)
{
struct sockaddr_in sin;
if (__ipparse(&sin, AF_INET, p)) return -1;
if (__ipparse(&sin, AF_INET, p) < 0) return -1;
return sin.sin_addr.s_addr;
}
......@@ -11,9 +11,9 @@ in_addr_t inet_network(const char *p)
int inet_aton(const char *cp, struct in_addr *inp)
{
struct sockaddr_in sin;
int r = __ipparse(&sin, AF_INET, cp);
if (__ipparse(&sin, AF_INET, cp) < 0) return 0;
*inp = sin.sin_addr;
return r;
return 1;
}
struct in_addr inet_makeaddr(int net, int host)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册