mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:02:56 +00:00
- Lets try this again. Re-implement inet_aton so that it does not fail in 255.255.255.255. See bug 3962 for more info.
svn path=/trunk/; revision=38364
This commit is contained in:
parent
15381523f2
commit
a7e5b19f4c
1 changed files with 27 additions and 2 deletions
|
@ -32,11 +32,36 @@ u_int32_t arc4random()
|
||||||
|
|
||||||
|
|
||||||
int inet_aton(const char *cp, struct in_addr *inp)
|
int inet_aton(const char *cp, struct in_addr *inp)
|
||||||
|
/* inet_addr code from ROS, slightly modified. */
|
||||||
{
|
{
|
||||||
inp->S_un.S_addr = inet_addr(cp);
|
ULONG Octets[4] = {0,0,0,0};
|
||||||
if (INADDR_NONE == inp->S_un.S_addr)
|
ULONG i = 0;
|
||||||
|
|
||||||
|
if(!cp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
while(*cp)
|
||||||
|
{
|
||||||
|
CHAR c = *cp;
|
||||||
|
cp++;
|
||||||
|
|
||||||
|
if(c == '.')
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(c < '0' || c > '9')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Octets[i] *= 10;
|
||||||
|
Octets[i] += (c - '0');
|
||||||
|
|
||||||
|
if(Octets[i] > 255)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inp->S_un.S_addr = (Octets[3] << 24) + (Octets[2] << 16) + (Octets[1] << 8) + Octets[0];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue