提交 b1460627 编写于 作者: R Richard Levitte

Make get_ip() a bit more strict in it's parsing of IP addresses, and

at the same time a bit more accepting with host names.
上级 5abc8ae6
...@@ -494,16 +494,16 @@ static int get_ip(const char *str, unsigned char ip[4]) ...@@ -494,16 +494,16 @@ static int get_ip(const char *str, unsigned char ip[4])
{ {
ok=1; ok=1;
tmp[num]=tmp[num]*10+c-'0'; tmp[num]=tmp[num]*10+c-'0';
if (tmp[num] > 255) return(-1); if (tmp[num] > 255) return(0);
} }
else if (c == '.') else if (c == '.')
{ {
if (!ok) return(-1); if (!ok) return(-1);
if (num == 3) break; if (num == 3) return(0);
num++; num++;
ok=0; ok=0;
} }
else if ((num == 3) && ok) else if (c == '\0' && (num == 3) && ok)
break; break;
else else
return(0); return(0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册