SonarCloud: try to appease it better

pull/576/head
Brad House 1 year ago
parent d35434d6bd
commit 3078f33333
  1. 21
      src/lib/ares_init.c
  2. 2
      src/lib/ares_process.c

@ -2064,15 +2064,20 @@ static ares_status_t config_sortlist(struct apattern **sortlist, size_t *nsort,
while (*str && *str != ';')
{
int bits;
char ipbuf[16], ipbufpfx[32];
char ipbuf[17], ipbufpfx[32];
size_t len;
/* Find just the IP */
q = str;
while (*q && *q != '/' && *q != ';' && !ISSPACE(*q))
q++;
if (q-str >= 16)
len = (size_t)(q-str);
if (len >= sizeof(ipbuf)-1)
return ARES_EBADSTR;
memcpy(ipbuf, str, (size_t)(q-str));
ipbuf[q-str] = '\0';
memcpy(ipbuf, str, len);
ipbuf[len] = '\0';
/* Find the prefix */
if (*q == '/')
{
@ -2120,10 +2125,12 @@ static ares_status_t config_sortlist(struct apattern **sortlist, size_t *nsort,
{
if (ipbufpfx[0])
{
if (q-str >= 16)
len = (size_t)(q-str);
if (len >= sizeof(ipbuf)-1)
return ARES_EBADSTR;
memcpy(ipbuf, str, (size_t)(q-str));
ipbuf[q-str] = '\0';
memcpy(ipbuf, str, len);
ipbuf[len] = '\0';
if (ip_addr(ipbuf, q-str, &pat.mask.addr4) != 0)
natural_mask(&pat);
}

@ -1040,7 +1040,7 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel)
}
}
else if (family == AF_INET6) {
if (memcmp(channel->local_ip6, &ares_in6addr_any,
if (memcmp(channel->local_ip6, ares_in6addr_any._S6_un._S6_u8,
sizeof(channel->local_ip6)) != 0) {
memset(&local.sa6, 0, sizeof(local.sa6));
local.sa6.sin6_family = AF_INET6;

Loading…
Cancel
Save