From: Victor Julien Date: Wed, 11 Dec 2013 09:11:13 +0000 (+0100) Subject: dns: fix passing NULL to memcpy X-Git-Tag: suricata-2.0beta2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ea13f0f53796401b1ad9d9d7921c3bb68c6bfd5;p=thirdparty%2Fsuricata.git dns: fix passing NULL to memcpy app-layer-dns-common.c:401:5: warning: Null pointer passed as \ an argument to a 'nonnull' parameter memcpy(ptr, fqdn, fqdn_len); --- diff --git a/src/app-layer-dns-common.c b/src/app-layer-dns-common.c index 5110902ec7..6e79fc1204 100644 --- a/src/app-layer-dns-common.c +++ b/src/app-layer-dns-common.c @@ -398,9 +398,13 @@ void DNSStoreAnswerInState(DNSState *dns_state, const int rtype, const uint8_t * q->data_len = data_len; uint8_t *ptr = (uint8_t *)q + sizeof(DNSAnswerEntry); - memcpy(ptr, fqdn, fqdn_len); - ptr += fqdn_len; - memcpy(ptr, data, data_len); + if (fqdn != NULL && fqdn_len > 0) { + memcpy(ptr, fqdn, fqdn_len); + ptr += fqdn_len; + } + if (data != NULL && data_len > 0) { + memcpy(ptr, data, data_len); + } if (rtype == DNS_LIST_ANSWER) TAILQ_INSERT_TAIL(&tx->answer_list, q, next);