Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | From 38cff19781f81586926b02f0fd1cb36c040395e0 Mon Sep 17 00:00:00 2001 |
| 2 | From: Nate Karstens <nate.karstens@garmin.com> |
| 3 | Date: Thu, 10 Aug 2017 08:21:53 -0500 |
| 4 | Subject: [PATCH 09/11] Fix possible NULL dereference |
| 5 | |
| 6 | Fixes a possible NULL dereference if memory for |
| 7 | the PosixNetworkInterface could not be allocated. |
| 8 | Other logic seems to prevent dereferencing this |
| 9 | variable if NULL, but this instance seems to have |
| 10 | been overlooked. |
| 11 | |
| 12 | Upstream-Status: Submitted [dts@apple.com] |
| 13 | |
| 14 | Signed-off-by: Nate Karstens <nate.karstens@garmin.com> |
| 15 | --- |
| 16 | mDNSPosix/mDNSPosix.c | 11 +++++++---- |
| 17 | 1 file changed, 7 insertions(+), 4 deletions(-) |
| 18 | |
| 19 | diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c |
| 20 | index a8a57df..3243ed4 100644 |
| 21 | --- a/mDNSPosix/mDNSPosix.c |
| 22 | +++ b/mDNSPosix/mDNSPosix.c |
| 23 | @@ -951,12 +951,15 @@ mDNSlocal int SetupOneInterface(mDNS *const m, struct ifi_info *const ifi) |
| 24 | |
| 25 | // If interface is a direct link, address record will be marked as kDNSRecordTypeKnownUnique |
| 26 | // and skip the probe phase of the probe/announce packet sequence. |
| 27 | - intf->coreIntf.DirectLink = mDNSfalse; |
| 28 | + if (err == 0) |
| 29 | + { |
| 30 | + intf->coreIntf.DirectLink = mDNSfalse; |
| 31 | #ifdef DIRECTLINK_INTERFACE_NAME |
| 32 | - if (strcmp(intfName, STRINGIFY(DIRECTLINK_INTERFACE_NAME)) == 0) |
| 33 | - intf->coreIntf.DirectLink = mDNStrue; |
| 34 | + if (strcmp(intfName, STRINGIFY(DIRECTLINK_INTERFACE_NAME)) == 0) |
| 35 | + intf->coreIntf.DirectLink = mDNStrue; |
| 36 | #endif |
| 37 | - intf->coreIntf.SupportsUnicastMDNSResponse = mDNStrue; |
| 38 | + intf->coreIntf.SupportsUnicastMDNSResponse = mDNStrue; |
| 39 | + } |
| 40 | |
| 41 | // The interface is all ready to go, let's register it with the mDNS core. |
| 42 | if (err == 0) |
| 43 | -- |
| 44 | 2.17.1 |
| 45 | |