Skip to content

Commit 3b26795

Browse files
committed
ext/standard: Use zend_string for path of move_uploaded_file()
1 parent 6360082 commit 3b26795

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ext/standard/basic_functions.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,32 +2354,33 @@ PHP_FUNCTION(is_uploaded_file)
23542354
/* {{{ Move a file if and only if it was created by an upload */
23552355
PHP_FUNCTION(move_uploaded_file)
23562356
{
2357-
char *path, *new_path;
2358-
size_t path_len, new_path_len;
2357+
zend_string *path;
2358+
char *new_path;
2359+
size_t new_path_len;
23592360
bool successful = 0;
23602361

23612362
#ifndef PHP_WIN32
23622363
int oldmask; int ret;
23632364
#endif
23642365

23652366
ZEND_PARSE_PARAMETERS_START(2, 2)
2366-
Z_PARAM_STRING(path, path_len)
2367+
Z_PARAM_STR(path) // TODO Should this use Z_PARAM_PATH_STR() ?
23672368
Z_PARAM_PATH(new_path, new_path_len)
23682369
ZEND_PARSE_PARAMETERS_END();
23692370

23702371
if (!SG(rfc1867_uploaded_files)) {
23712372
RETURN_FALSE;
23722373
}
23732374

2374-
if (!zend_hash_str_exists(SG(rfc1867_uploaded_files), path, path_len)) {
2375+
if (!zend_hash_exists(SG(rfc1867_uploaded_files), path)) {
23752376
RETURN_FALSE;
23762377
}
23772378

23782379
if (php_check_open_basedir(new_path)) {
23792380
RETURN_FALSE;
23802381
}
23812382

2382-
if (VCWD_RENAME(path, path_len, new_path, new_path_len) == 0) {
2383+
if (VCWD_RENAME(ZSTR_VAL(path), ZSTR_LEN(path), new_path, new_path_len) == 0) {
23832384
successful = 1;
23842385
#ifndef PHP_WIN32
23852386
oldmask = umask(077);
@@ -2391,15 +2392,15 @@ PHP_FUNCTION(move_uploaded_file)
23912392
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
23922393
}
23932394
#endif
2394-
} else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR) == SUCCESS) {
2395-
VCWD_UNLINK(path);
2395+
} else if (php_copy_file_ex(ZSTR_VAL(path), new_path, STREAM_DISABLE_OPEN_BASEDIR) == SUCCESS) {
2396+
VCWD_UNLINK(ZSTR_VAL(path));
23962397
successful = 1;
23972398
}
23982399

23992400
if (successful) {
2400-
zend_hash_str_del(SG(rfc1867_uploaded_files), path, path_len);
2401+
zend_hash_del(SG(rfc1867_uploaded_files), path);
24012402
} else {
2402-
php_error_docref(NULL, E_WARNING, "Unable to move \"%s\" to \"%s\"", path, new_path);
2403+
php_error_docref(NULL, E_WARNING, "Unable to move \"%s\" to \"%s\"", ZSTR_VAL(path), new_path);
24032404
}
24042405

24052406
RETURN_BOOL(successful);

0 commit comments

Comments
 (0)