Skip to content

Commit 75e3b81

Browse files
committed
Avoid input string duplication in OnUpdateBaseDir MH handler
1 parent a21d567 commit 75e3b81

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

main/fopen_wrappers.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
9494

9595
/* Is the proposed open_basedir at least as restrictive as the current setting? */
9696
smart_string buf = {0};
97-
ptr = pathbuf = estrdup(ZSTR_VAL(new_value));
97+
ptr = pathbuf = ZSTR_VAL(new_value);
9898
while (ptr && *ptr) {
9999
end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
100100
if (end != NULL) {
@@ -103,13 +103,11 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
103103
}
104104
char resolved_name[MAXPATHLEN + 1];
105105
if (expand_filepath(ptr, resolved_name) == NULL) {
106-
efree(pathbuf);
107106
smart_string_free(&buf);
108107
return FAILURE;
109108
}
110109
if (php_check_open_basedir_ex(resolved_name, 0) != 0) {
111110
/* At least one portion of this open_basedir is less restrictive than the prior one, FAIL */
112-
efree(pathbuf);
113111
smart_string_free(&buf);
114112
return FAILURE;
115113
}
@@ -119,7 +117,6 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
119117
smart_string_appends(&buf, resolved_name);
120118
ptr = end;
121119
}
122-
efree(pathbuf);
123120

124121
/* Everything checks out, set it */
125122
smart_string_0(&buf);

0 commit comments

Comments
 (0)