Skip to content

Commit 25d8666

Browse files
committed
ext/standard: Throw ValueError for empty paths in copy()
1 parent e63dc47 commit 25d8666

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

ext/standard/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,15 +1439,15 @@ PHPAPI zend_result php_copy_file_ex(const char *src, const char *dest, int src_f
14391439
/* }}} */
14401440

14411441
/* {{{ php_copy_file_ctx */
1442-
PHPAPI zend_result php_copy_file_ctx(const char *src, const char *dest, int src_flags, php_stream_context *ctx)
1442+
ZEND_ATTRIBUTE_NONNULL_ARGS(1,2) PHPAPI zend_result php_copy_file_ctx(const char *src, const char *dest, int src_flags, php_stream_context *ctx)
14431443
{
14441444
php_stream *srcstream = NULL, *deststream = NULL;
14451445
zend_result ret = FAILURE;
14461446
php_stream_statbuf src_s, dest_s;
14471447
int src_stat_flags = (src_flags & STREAM_DISABLE_OPEN_BASEDIR) ? PHP_STREAM_URL_STAT_IGNORE_OPEN_BASEDIR : 0;
14481448

14491449
if (!dest||!*dest) {
1450-
zend_argument_value_error(2, "cannot be empty");
1450+
zend_argument_must_not_be_empty_error(2);
14511451
return FAILURE;
14521452
}
14531453

ext/standard/file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PHP_MINIT_FUNCTION(user_streams);
3838

3939
PHPAPI zend_result php_copy_file(const char *src, const char *dest);
4040
PHPAPI zend_result php_copy_file_ex(const char *src, const char *dest, int src_flags);
41-
PHPAPI zend_result php_copy_file_ctx(const char *src, const char *dest, int src_flags, php_stream_context *ctx);
41+
ZEND_ATTRIBUTE_NONNULL_ARGS(1,2) PHPAPI zend_result php_copy_file_ctx(const char *src, const char *dest, int src_flags, php_stream_context *ctx);
4242
PHPAPI void php_fstat(php_stream *stream, zval *return_value);
4343
PHPAPI void php_flock_common(php_stream *stream, zend_long operation, uint32_t operation_arg_num,
4444
zval *wouldblock, zval *return_value);

ext/standard/tests/file/copy_empty_path.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ $dir = __DIR__;
2828
?>
2929
--EXPECT--
3030
Path must not be empty
31-
copy(): Argument #2 ($to) cannot be empty
31+
copy(): Argument #2 ($to) must not be empty

0 commit comments

Comments
 (0)