diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-19 08:52:21 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-20 11:23:32 +0200 |
commit | f761b290f135957f47e1c9af71b4a81c76c32b48 (patch) | |
tree | 2b7d273db4ff2388867efec5ad432fa49cd4047e /mDNSResponder/mDNSMacOSX/helper-stubs.c | |
parent | mDNSResponder: Update to v576.30.4 (diff) | |
download | rtems-libbsd-f761b290f135957f47e1c9af71b4a81c76c32b48.tar.bz2 |
mDNSResponder: Update to v625.41.2
The sources can be obtained via:
https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-625.41.2.tar.gz
Update #3522.
Diffstat (limited to 'mDNSResponder/mDNSMacOSX/helper-stubs.c')
-rw-r--r-- | mDNSResponder/mDNSMacOSX/helper-stubs.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/mDNSResponder/mDNSMacOSX/helper-stubs.c b/mDNSResponder/mDNSMacOSX/helper-stubs.c index 29fd9aed..e08f5050 100644 --- a/mDNSResponder/mDNSMacOSX/helper-stubs.c +++ b/mDNSResponder/mDNSMacOSX/helper-stubs.c @@ -1,5 +1,6 @@ -/* - * Copyright (c) 2007-2012 Apple Inc. All rights reserved. +/* -*- Mode: C; tab-width: 4 -*- + * + * Copyright (c) 2007-2015 Apple Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -169,26 +170,28 @@ void mDNSNotify(const char *title, const char *msg) // Both strings are UTF-8 te if (title) { + // Don’t try to call mDNSPlatformMem* routines here, because they call validatelists, + // which calls back into mDNSNotify, resulting an infinite loop until stack space is exhausted int len = strlen(title); - titleCopy = mDNSPlatformMemAllocate(len + 1); + titleCopy = malloc(len + 1); if (!titleCopy) { LogMsg("mDNSNotify: titleCopy NULL for %s", msg); return; } - mDNSPlatformMemCopy(titleCopy, title, len); + memcpy(titleCopy, title, len); titleCopy[len] = 0; } if (msg) { int len = strlen(msg); - msgCopy = mDNSPlatformMemAllocate(len + 1); + msgCopy = malloc(len + 1); if (!msgCopy) { LogMsg("mDNSNotify: msgCopy NULL for %s", msg); return; } - mDNSPlatformMemCopy(msgCopy, msg, len); + memcpy(msgCopy, msg, len); msgCopy[len] = 0; } @@ -203,10 +206,10 @@ void mDNSNotify(const char *title, const char *msg) // Both strings are UTF-8 te kr = proxy_mDNSNotify(getHelperPort(retry), titleCopy, msgCopy); MACHRETRYLOOP_END(kr, retry, err, fin); fin: - if (titleCopy) - mDNSPlatformMemFree(titleCopy); - if (msgCopy) - mDNSPlatformMemFree(msgCopy); + // Don’t try to call mDNSPlatformMem* routines here, because they call validatelists, + // which calls back into mDNSNotify, resulting an infinite loop until stack space is exhausted + free(titleCopy); + free(msgCopy); (void)err; }); } @@ -231,7 +234,7 @@ int mDNSKeychainGetSecrets(CFArrayRef *result) LogMsg("%s: CFDataCreateWithBytesNoCopy failed", __func__); goto fin; } - if (NULL == (plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, bytes, kCFPropertyListImmutable, NULL))) + if (NULL == (plist = CFPropertyListCreateWithData(kCFAllocatorDefault, bytes, kCFPropertyListImmutable, NULL, NULL))) { err = kmDNSHelperInvalidPList; LogMsg("%s: CFPropertyListCreateFromXMLData failed", __func__); @@ -456,7 +459,7 @@ void mDNSGetRemoteMAC(mDNS *const m, int family, v6addr_t raddr) // the values and schedule a task to update the MAC address in the TCP Keepalive record. if (kr == KERN_SUCCESS) { - addrMapping = (IPAddressMACMapping *)malloc(sizeof(IPAddressMACMapping)); + addrMapping = mDNSPlatformMemAllocate(sizeof(IPAddressMACMapping)); snprintf(addrMapping->ethaddr, sizeof(addrMapping->ethaddr), "%02x:%02x:%02x:%02x:%02x:%02x", eth[0], eth[1], eth[2], eth[3], eth[4], eth[5]); if (family == AF_INET) |