Created
April 8, 2015 15:50
-
-
Save gdamore/20542d8043f764dcb5ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
garrett@hipster{25}> git diff uts/common/os/exec.c | cat | |
diff --git a/usr/src/uts/common/os/exec.c b/usr/src/uts/common/os/exec.c | |
index f222a20..611a6f3 100644 | |
--- a/usr/src/uts/common/os/exec.c | |
+++ b/usr/src/uts/common/os/exec.c | |
@@ -100,6 +100,7 @@ uint_t auxv_hwcap32_2 = 0; /* 32-bit version of auxv_hwcap2 */ | |
#define PSUIDFLAGS (SNOCD|SUGID) | |
#define DEVFD "/dev/fd/" | |
+#define DEVFD_STRLEN (sizeof (DEVFD) - 1) | |
/* | |
* exece() - system call wrapper around exec_common() | |
@@ -202,11 +203,12 @@ exec_common(const char *fname, const char **argp, const char **envp, | |
goto out; | |
pn_alloc(&resolvepn); | |
- if (strncmp(pn.pn_path, DEVFD, strlen(DEVFD)) == 0) { | |
+ if ((strncmp(pn.pn_path, DEVFD, DEVFD_STRLEN) == 0) && | |
+ (pn.pn_path[DEVFD_STRLEN] != '\0')) { | |
/* looks like a /dev/fd node */ | |
- char *p = pn.pn_path + strlen(DEVFD); | |
+ char *p = pn.pn_path + DEVFD_STRLEN; | |
int fd = stoi(&p); | |
- if ((fd < 0) || (*p != 0) || (p == pn.pn_path)) { | |
+ if ((fd < 0) || (*p != '\0')) { | |
error = EBADF; | |
goto out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment