]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/sysctl.c.patch
Libc-763.12.tar.gz
[apple/libc.git] / gen / FreeBSD / sysctl.c.patch
CommitLineData
1f2f436a
A
1--- sysctl.c.orig 2010-06-30 01:03:07.000000000 -0700
2+++ sysctl.c 2010-07-01 23:10:13.000000000 -0700
3@@ -53,8 +53,34 @@ sysctl(name, namelen, oldp, oldlenp, new
4 void *oldp, *newp;
5 size_t *oldlenp, newlen;
6 {
7- if (name[0] != CTL_USER)
8+ if (name[0] != CTL_USER) {
9+ if (namelen == 2 && name[0] == CTL_KERN && name[1] == KERN_EXEC) {
10+ /*
11+ * 7723306: intercept kern.exec and fake a return of
12+ * a dummy string ("/" in this case)
13+ */
14+ if (newp != NULL) {
15+ errno = EPERM;
16+ return -1;
17+ }
18+ if (oldp == NULL) {
19+ if (oldlenp != NULL) *oldlenp = 2;
20+ return 0;
21+ }
22+ if (oldlenp == NULL) {
23+ errno = EFAULT;
24+ return -1;
25+ }
26+ if (*oldlenp < 2) {
27+ errno = ENOMEM;
28+ return -1;
29+ }
30+ memmove(oldp, "/", 2);
31+ *oldlenp = 2;
32+ return 0;
33+ }
34 return (__sysctl(name, namelen, oldp, oldlenp, newp, newlen));
35+ }
36
37 if (newp != NULL) {
38 errno = EPERM;