Revision: 23583 http://trac.macosforge.org/projects/launchd/changeset/23583 Author: zarzycki@apple.com Date: 2008-04-02 10:31:16 -0700 (Wed, 02 Apr 2008) Log Message: ----------- <rdar://problem/5835665> 10A41: SystemStarter crashes when FORTIFY is enabled Modified Paths: -------------- trunk/launchd/src/StartupItems.c Modified: trunk/launchd/src/StartupItems.c =================================================================== --- trunk/launchd/src/StartupItems.c 2008-04-02 16:43:05 UTC (rev 23582) +++ trunk/launchd/src/StartupItems.c 2008-04-02 17:31:16 UTC (rev 23583) @@ -286,7 +286,7 @@ while ((aState = NSGetNextSearchPathEnumeration(aState, aPath))) { DIR *aDirectory; - strcpy(aPath + strlen(aPath), kStartupItemsPath); + strlcat(aPath, kStartupItemsPath, sizeof(aPath)); ++aDomainIndex; /* 5485016 @@ -923,29 +923,18 @@ anError = 0; } else { CFStringRef aBundlePathString = CFDictionaryGetValue(anItem, kBundlePathKey); - size_t aBundlePathCLength = - CFStringGetMaximumSizeForEncoding(CFStringGetLength(aBundlePathString), kCFStringEncodingUTF8) + 1; - char *aBundlePath = (char *)malloc(aBundlePathCLength); - char anExecutable[PATH_MAX] = ""; + char aBundlePath[PATH_MAX]; + char anExecutable[PATH_MAX]; + char *tmp; - if (!aBundlePath) { - syslog(LOG_EMERG, "malloc() failed; out of memory while running item %s", aBundlePathString); - return (anError); - } - if (!CFStringGetCString(aBundlePathString, aBundlePath, aBundlePathCLength, kCFStringEncodingUTF8)) { + if (!CFStringGetCString(aBundlePathString, aBundlePath, sizeof(aBundlePath), kCFStringEncodingUTF8)) { CF_syslog(LOG_EMERG, CFSTR("Internal error while running item %@"), aBundlePathString); return (anError); } /* Compute path to excecutable */ - { - char *tmp; - strncpy(anExecutable, aBundlePath, sizeof(anExecutable)); /* .../foo */ - tmp = rindex(anExecutable, '/'); /* /foo */ - strncat(anExecutable, tmp, strlen(tmp)); /* .../foo/foo */ - } + tmp = rindex(aBundlePath, '/'); + snprintf(anExecutable, sizeof(anExecutable), "%s%s", aBundlePath, tmp); - free(aBundlePath); - /** * Run the bundle **/
participants (1)
-
source_changes@macosforge.org