mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
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.
This commit is contained in:
parent
f0589da0e3
commit
01e1dc0e62
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user