Projects
Browse Source     Search     Timeline     Wiki

Changeset 23583

Show
Ignore:
Timestamp:
04/02/08 10:31:16 (8 months ago)
Author:
zarzycki@…
Message:

<rdar://problem/5835665> 10A41: SystemStarter crashes when FORTIFY is enabled

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/StartupItems.c

    r23429 r23583  
    287287                DIR *aDirectory; 
    288288 
    289                 strcpy(aPath + strlen(aPath), kStartupItemsPath); 
     289                strlcat(aPath, kStartupItemsPath, sizeof(aPath)); 
    290290                ++aDomainIndex; 
    291291 
     
    924924        } else { 
    925925                CFStringRef aBundlePathString = CFDictionaryGetValue(anItem, kBundlePathKey); 
    926                 size_t aBundlePathCLength = 
    927                     CFStringGetMaximumSizeForEncoding(CFStringGetLength(aBundlePathString), kCFStringEncodingUTF8) + 1; 
    928                 char *aBundlePath = (char *)malloc(aBundlePathCLength); 
    929                 char anExecutable[PATH_MAX] = ""; 
    930  
    931                 if (!aBundlePath) { 
    932                         syslog(LOG_EMERG, "malloc() failed; out of memory while running item %s", aBundlePathString); 
    933                         return (anError); 
    934                 } 
    935                 if (!CFStringGetCString(aBundlePathString, aBundlePath, aBundlePathCLength, kCFStringEncodingUTF8)) { 
     926                char aBundlePath[PATH_MAX]; 
     927                char anExecutable[PATH_MAX]; 
     928                char *tmp; 
     929 
     930                if (!CFStringGetCString(aBundlePathString, aBundlePath, sizeof(aBundlePath), kCFStringEncodingUTF8)) { 
    936931                        CF_syslog(LOG_EMERG, CFSTR("Internal error while running item %@"), aBundlePathString); 
    937932                        return (anError); 
    938933                } 
    939934                /* Compute path to excecutable */ 
    940                 { 
    941                         char           *tmp; 
    942                         strncpy(anExecutable, aBundlePath, sizeof(anExecutable));       /* .../foo     */ 
    943                         tmp = rindex(anExecutable, '/');        /* /foo        */ 
    944                         strncat(anExecutable, tmp, strlen(tmp));        /* .../foo/foo */ 
    945                 } 
    946  
    947                 free(aBundlePath); 
     935                tmp = rindex(aBundlePath, '/'); 
     936                snprintf(anExecutable, sizeof(anExecutable), "%s%s", aBundlePath, tmp); 
    948937 
    949938                /**