Commit 2c872643 authored by Robert Loehning's avatar Robert Loehning Committed by Fawzi Mohamed
Browse files

zeroconf/dnssd_clientstub: avoid possible null dereferencing



Moved check for NULL-pointer earlier

Change-Id: I764bd3c6c0545e7fa0784327375cdf7d06b29a31
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 930a2e16
......@@ -608,7 +608,7 @@ static DNSServiceErrorType ConnectToServer(DNSServiceRef *ref, DNSServiceFlags f
static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
{
uint32_t datalen = hdr->datalen; // We take a copy here because we're going to convert hdr->datalen to network byte order
uint32_t datalen;
#if defined(USE_TCP_LOOPBACK) || defined(USE_NAMED_ERROR_RETURN_SOCKET)
char *const data = (char *)hdr + sizeof(ipc_msg_hdr);
#endif
......@@ -616,6 +616,10 @@ static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
DNSServiceErrorType err = kDNSServiceErr_Unknown; // Default for the "goto cleanup" cases
int MakeSeparateReturnSocket = 0;
if (!hdr) { syslog(LOG_WARNING, "dnssd_clientstub deliver_request: !hdr"); return kDNSServiceErr_Unknown; }
datalen = hdr->datalen; // We take a copy here because we're going to convert hdr->datalen to network byte order
// Note: need to check hdr->op, not sdr->op.
// hdr->op contains the code for the specific operation we're currently doing, whereas sdr->op
// contains the original parent DNSServiceOp (e.g. for an add_record_request, hdr->op will be
......@@ -630,8 +634,6 @@ static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
return kDNSServiceErr_BadReference;
}
if (!hdr) { syslog(LOG_WARNING, "dnssd_clientstub deliver_request: !hdr"); return kDNSServiceErr_Unknown; }
if (MakeSeparateReturnSocket)
{
#if defined(USE_TCP_LOOPBACK)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment