fix coverity issue 1372473 Out-of-bounds write

This commit is contained in:
Vincent Sanders 2017-06-09 19:51:12 +01:00
parent 703427a486
commit 2467a0a990

View File

@ -696,8 +696,8 @@ static bool urldb__host_is_ip_address(const char *host)
}
ipv6_addr_len = host_len - 2;
if (ipv6_addr_len > sizeof(ipv6_addr)) {
ipv6_addr_len = sizeof(ipv6_addr);
if (ipv6_addr_len >= sizeof(ipv6_addr)) {
ipv6_addr_len = sizeof(ipv6_addr) - 1;
}
strncpy(ipv6_addr, sane_host + 1, ipv6_addr_len);
ipv6_addr[ipv6_addr_len] = '\0';