aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Sundman <anders@4zm.org>2011-11-11 07:47:00 +0100
committerAnders Sundman <anders@4zm.org>2011-11-11 07:47:00 +0100
commit01e1dc0e6227a8d7e107e41cf19ac9c68d47e7b7 (patch)
tree77b78b52267f36099bad9102b475a3cc215bf18c
parentf0589da0e3270e627ac6fd249976234a4c085d3f (diff)
downloadtor-01e1dc0e6227a8d7e107e41cf19ac9c68d47e7b7.tar.gz
tor-01e1dc0e6227a8d7e107e41cf19ac9c68d47e7b7.zip
Fixed of-by-one error in tor_inet_ntop
The of-by-one error could lead to 1 byte buffer over runs IPv6 for addresses.
-rw-r--r--src/common/compat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 2cf7f463c1..ba49af757c 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1632,7 +1632,7 @@ tor_inet_ntop(int af, const void *src, char *dst, size_t len)
addr->s6_addr[12], addr->s6_addr[13],
addr->s6_addr[14], addr->s6_addr[15]);
}
- if (strlen(buf) > len)
+ if ((strlen(buf) + 1) > len) /* +1 for \0 */
return NULL;
strlcpy(dst, buf, len);
return dst;
@@ -1673,7 +1673,7 @@ tor_inet_ntop(int af, const void *src, char *dst, size_t len)
}
}
*cp = '\0';
- if (strlen(buf) > len)
+ if ((strlen(buf) + 1) > len) /* +1 for \0 */
return NULL;
strlcpy(dst, buf, len);
return dst;