if ((envpath = getenv("PATH")) != NULL) {
char *search_dir, search_path[MAXPATHLEN];
char *last;
- int pathlen = strlen(envpath) + 1;
- path = malloc(pathlen);
- memcpy(path, envpath, pathlen);
+ path = estrdup(envpath);
search_dir = php_strtok_r(path, ":", &last);
+
while (search_dir) {
snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location);
if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK)) {
}
search_dir = php_strtok_r(NULL, ":", &last);
}
+ efree(path);
}
if (!found) {
efree(binary_location);