提交 ac45692a 编写于 作者: S Szabolcs Nagy

remove an unnecessary check in inet_pton

at most 4 hexadecimal digits are processed in one field so the
value cannot overflow. the netdb.h header was not used.
上级 ec411999
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
...@@ -46,7 +45,7 @@ int inet_pton(int af, const char *restrict s, void *restrict a0) ...@@ -46,7 +45,7 @@ int inet_pton(int af, const char *restrict s, void *restrict a0)
} }
for (v=j=0; j<4 && (d=hexval(s[j]))>=0; j++) for (v=j=0; j<4 && (d=hexval(s[j]))>=0; j++)
v=16*v+d; v=16*v+d;
if (j==0 || v > 65535) return 0; if (j==0) return 0;
ip[i] = v; ip[i] = v;
if (!s[j] && (brk>=0 || i==7)) break; if (!s[j] && (brk>=0 || i==7)) break;
if (i==7) return 0; if (i==7) return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册