From 5bef433eb86ecf3dcb303c8adf985cbb6dd9327c Mon Sep 17 00:00:00 2001 From: Jonas <40121984+JonasQuinten@users.noreply.github.com> Date: Sun, 28 May 2023 03:47:27 +0200 Subject: [PATCH 1/2] fix: use zval_get_long() to read value of FTP context option "overwrite" --- ext/standard/ftp_fopen_wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index f20f4245bd469..901f271733986 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -490,7 +490,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa } else if (read_write == 2) { /* when writing file (but not appending), it must NOT exist, unless a context option exists which allows it */ if (context && (tmpzval = php_stream_context_get_option(context, "ftp", "overwrite")) != NULL) { - allow_overwrite = Z_LVAL_P(tmpzval) ? 1 : 0; + allow_overwrite = zval_get_long(tmpzval) != 0; } if (result <= 299 && result >= 200) { if (allow_overwrite) { From 5b8d12c600e063e01b94cd3aa01784fe10bea7bc Mon Sep 17 00:00:00 2001 From: Jonas <40121984+JonasQuinten@users.noreply.github.com> Date: Sun, 28 May 2023 18:24:33 +0200 Subject: [PATCH 2/2] use zend_is_true() instead of zval_get_long() --- ext/standard/ftp_fopen_wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index 901f271733986..d19113f7c77a1 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -490,7 +490,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa } else if (read_write == 2) { /* when writing file (but not appending), it must NOT exist, unless a context option exists which allows it */ if (context && (tmpzval = php_stream_context_get_option(context, "ftp", "overwrite")) != NULL) { - allow_overwrite = zval_get_long(tmpzval) != 0; + allow_overwrite = zend_is_true(tmpzval); } if (result <= 299 && result >= 200) { if (allow_overwrite) {