Skip to content

Commit

Permalink
Fix a bug in the checking of the return value of inet_aton
Browse files Browse the repository at this point in the history
  • Loading branch information
montag451 committed Jan 14, 2014
1 parent 9a3e03e commit 22388f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pytun.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static int pytun_tuntap_set_addr(PyObject* self, PyObject* value, void* d)
strcpy(req.ifr_name, tuntap->name);
sin = (struct sockaddr_in*)&req.ifr_addr;
sin->sin_family = AF_INET;
if (inet_aton(addr, &sin->sin_addr) < 0)
if (inet_aton(addr, &sin->sin_addr) == 0)
{
raise_error("Bad IP address");
ret = -1;
Expand Down Expand Up @@ -315,7 +315,7 @@ static int pytun_tuntap_set_dstaddr(PyObject* self, PyObject* value, void* d)
strcpy(req.ifr_name, tuntap->name);
sin = (struct sockaddr_in*)&req.ifr_dstaddr;
sin->sin_family = AF_INET;
if (inet_aton(dstaddr, &sin->sin_addr) < 0)
if (inet_aton(dstaddr, &sin->sin_addr) == 0)
{
raise_error("Bad IP address");
ret = -1;
Expand Down Expand Up @@ -438,7 +438,7 @@ static int pytun_tuntap_set_netmask(PyObject* self, PyObject* value, void* d)
strcpy(req.ifr_name, tuntap->name);
sin = (struct sockaddr_in*)&req.ifr_netmask;
sin->sin_family = AF_INET;
if (inet_aton(netmask, &sin->sin_addr) < 0)
if (inet_aton(netmask, &sin->sin_addr) == 0)
{
raise_error("Bad IP address");
ret = -1;
Expand Down

0 comments on commit 22388f8

Please sign in to comment.