fix stringop-overflow warning of GCC (#201)

When using a modern GCC to compile c-ares, there is a stringop-overflow warning. 
This patch simply silences the false-positive warning, there is no actual code flaw.

Bug: https://github.com/c-ares/c-ares/pull/201
Fixed By: Andi Schnebinger @Iniesta8
pull/202/head
Andi Schnebinger 7 years ago committed by Brad House
parent b93997b678
commit 7ebedab25d
  1. 6
      ares_parse_ptr_reply.c

@ -52,6 +52,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
int aliascnt = 0;
int alias_alloc = 8;
char ** aliases;
size_t rr_data_len;
/* Set *host to NULL for all failure cases. */
*host = NULL;
@ -124,14 +125,15 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
if (hostname)
ares_free(hostname);
hostname = rr_data;
aliases[aliascnt] = ares_malloc((strlen(rr_data)+1) * sizeof(char));
rr_data_len = strlen(rr_data)+1;
aliases[aliascnt] = ares_malloc(rr_data_len * sizeof(char));
if (!aliases[aliascnt])
{
ares_free(rr_name);
status = ARES_ENOMEM;
break;
}
strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1);
strncpy(aliases[aliascnt], rr_data, rr_data_len);
aliascnt++;
if (aliascnt >= alias_alloc) {
char **ptr;

Loading…
Cancel
Save