Revision
23273
Author
zarzycki@apple.com
Date
2007-06-06 09:04:51 -0700 (Wed, 06 Jun 2007)

Log Message

<rdar://problem/5253449> launchctl:do_sysversion_sysctl() does not have any safety checks

Modified Paths

Diff

Modified: trunk/launchd/src/launchctl.c (23272 => 23273)


--- trunk/launchd/src/launchctl.c	2007-06-04 18:26:07 UTC (rev 23272)
+++ trunk/launchd/src/launchctl.c	2007-06-06 16:04:51 UTC (rev 23273)
@@ -2887,12 +2887,14 @@
 		return;
 	}
 
-	versdict = _CFCopySystemVersionDictionary();
-	buildvers = CFDictionaryGetValue(versdict, _kCFSystemVersionBuildVersionKey);
-	CFStringGetCString(buildvers, buf, sizeof(buf), kCFStringEncodingUTF8);
+	if (!assumes((versdict = _CFCopySystemVersionDictionary()))) {
+		return;
+	}
 
-	if (sysctl(mib, 2, NULL, 0, buf, strlen(buf) + 1) == -1) {
-		fprintf(stderr, "sysctl(): %s\n", strerror(errno));
+	if (assumes((buildvers = CFDictionaryGetValue(versdict, _kCFSystemVersionBuildVersionKey)))) {
+		CFStringGetCString(buildvers, buf, sizeof(buf), kCFStringEncodingUTF8);
+
+		assumes(sysctl(mib, 2, NULL, 0, buf, strlen(buf) + 1) != -1);
 	}
 
 	CFRelease(versdict);