Changeset View
Changeset View
Standalone View
Standalone View
head/libexec/rtld-elf/rtld.c
Show First 20 Lines • Show All 5,525 Lines • ▼ Show 20 Lines | if (search_in_path && strchr(argv0, '/') == NULL) { | ||||
pathenv = strdup(pathenv); | pathenv = strdup(pathenv); | ||||
if (pathenv == NULL) { | if (pathenv == NULL) { | ||||
_rtld_error("Cannot allocate memory"); | _rtld_error("Cannot allocate memory"); | ||||
rtld_die(); | rtld_die(); | ||||
} | } | ||||
fd = -1; | fd = -1; | ||||
errno = ENOENT; | errno = ENOENT; | ||||
while ((pe = strsep(&pathenv, ":")) != NULL) { | while ((pe = strsep(&pathenv, ":")) != NULL) { | ||||
if (strlcpy(binpath, pe, sizeof(binpath)) >= | if (strlcpy(binpath, pe, PATH_MAX) >= PATH_MAX) | ||||
sizeof(binpath)) | |||||
continue; | continue; | ||||
if (binpath[0] != '\0' && | if (binpath[0] != '\0' && | ||||
strlcat(binpath, "/", sizeof(binpath)) >= | strlcat(binpath, "/", PATH_MAX) >= PATH_MAX) | ||||
sizeof(binpath)) | |||||
continue; | continue; | ||||
if (strlcat(binpath, argv0, sizeof(binpath)) >= | if (strlcat(binpath, argv0, PATH_MAX) >= PATH_MAX) | ||||
sizeof(binpath)) | |||||
continue; | continue; | ||||
fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY); | fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY); | ||||
if (fd != -1 || errno != ENOENT) { | if (fd != -1 || errno != ENOENT) { | ||||
*binpath_res = binpath; | *binpath_res = binpath; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
free(pathenv); | free(pathenv); | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |