summaryrefslogtreecommitdiff
path: root/lib/addns
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2015-06-23 10:10:19 +0200
committerJeremy Allison <jra@samba.org>2015-06-23 22:12:08 +0200
commit4bd430e05d4cef412a799cfbb60cc8339f2096c5 (patch)
tree1400daa4f7969f1db7947ea15107e2fce3cbbed0 /lib/addns
parent69160e55db06b0bf5987e3e39c9b584f19cb902f (diff)
downloadsamba-4bd430e05d4cef412a799cfbb60cc8339f2096c5.tar.gz
lib: Fix CID 1034723 Explicit null dereferenced
Do an early return if there's nothing to receive Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/addns')
-rw-r--r--lib/addns/dnssock.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/addns/dnssock.c b/lib/addns/dnssock.c
index b1d794db456..df175234397 100644
--- a/lib/addns/dnssock.c
+++ b/lib/addns/dnssock.c
@@ -321,13 +321,14 @@ static DNS_ERROR dns_receive_tcp(TALLOC_CTX *mem_ctx,
buf->size = ntohs(len);
- if (buf->size) {
- if (!(buf->data = talloc_array(buf, uint8_t, buf->size))) {
- TALLOC_FREE(buf);
- return ERROR_DNS_NO_MEMORY;
- }
- } else {
- buf->data = NULL;
+ if (buf->size == 0) {
+ *presult = buf;
+ return ERROR_DNS_SUCCESS;
+ }
+
+ if (!(buf->data = talloc_array(buf, uint8_t, buf->size))) {
+ TALLOC_FREE(buf);
+ return ERROR_DNS_NO_MEMORY;
}
err = read_all(conn->s, buf->data, buf->size);