summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-04-06 23:31:03 +0200
committerMartin Mares <mj@ucw.cz>1999-04-06 23:31:03 +0200
commit7976a574b692f747d833d899caf0fbbf702714c1 (patch)
treeef1770a42e2a87961e3fb3886b42b8f28fe7749c
parente2dc2f30efd65cf3da4db150fae695978388e247 (diff)
downloadbird-7976a574b692f747d833d899caf0fbbf702714c1.tar
bird-7976a574b692f747d833d899caf0fbbf702714c1.zip
ip_pton: Avoid modification of the string we're converting.
-rw-r--r--lib/ipv4.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/ipv4.c b/lib/ipv4.c
index 54e1adb..04e15b0 100644
--- a/lib/ipv4.c
+++ b/lib/ipv4.c
@@ -81,12 +81,12 @@ ip_pton(char *a, ip_addr *o)
char *d, *c = strchr(a, '.');
if (!c != !i)
return 0;
- if (c)
- *c++ = 0;
l = strtoul(a, &d, 10);
- if (d && *d || l > 255)
+ if (d != c && *d || l > 255)
return 0;
ia = (ia << 8) | l;
+ if (c)
+ c++;
a = c;
}
*o = ipa_from_u32(ia);