diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-19 13:07:30 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-19 13:14:33 -0400 |
commit | 685d450ab3823c578514ce6986d00c6e219abb43 (patch) | |
tree | c77c498342ce2e81553f03eb25b587f1613bcc5f /src/test/test_addr.c | |
parent | 78f555a2480b03911e602c2c041a10fd010804b9 (diff) | |
download | tor-685d450ab3823c578514ce6986d00c6e219abb43.tar.gz tor-685d450ab3823c578514ce6986d00c6e219abb43.zip |
scan-build: avoid undef behaior in tor_inet_pton
If we had an address of the form "1.2.3.4" and we tried to pass it to
tor_inet_pton with AF_INET6, it was possible for our 'eow' pointer to
briefly move backwards to the point before the start of the string,
before we moved it right back to the start of the string. C doesn't
allow that, and though we haven't yet hit a compiler that decided to
nuke us in response, it's best to fix.
So, be more explicit about requiring there to be a : before any IPv4
address part of the IPv6 address. We would have rejected addresses
without a : for not being IPv6 later on anyway.
Diffstat (limited to 'src/test/test_addr.c')
-rw-r--r-- | src/test/test_addr.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/test/test_addr.c b/src/test/test_addr.c index cee2dcf2a0..50011e606b 100644 --- a/src/test/test_addr.c +++ b/src/test/test_addr.c @@ -346,6 +346,9 @@ test_addr_ip6_helpers(void) test_pton6_bad("a:::b:c"); test_pton6_bad(":::a:b:c"); test_pton6_bad("a:b:c:::"); + test_pton6_bad("1.2.3.4"); + test_pton6_bad(":1.2.3.4"); + test_pton6_bad(".2.3.4"); /* test internal checking */ test_external_ip("fbff:ffff::2:7", 0); |