From e97ac117288d9dae7f36e375329c65994843509b Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 22 Jul 2021 08:37:07 +0200 Subject: Fix segmentation fault in uploadprogress, patch from https://github.com/php/pecl-php-uploadprogress/pull/8 Add arginfo to functions, patch from https://github.com/php/pecl-php-uploadprogress/pull/9 --- php-pecl-uploadprogress.spec | 48 +++++++++++++++---------------- uploadprogress-arginfo.patch | 40 ++++++++++++++++++++++++++ uploadprogress-segfault.patch | 66 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 24 deletions(-) create mode 100644 uploadprogress-arginfo.patch create mode 100644 uploadprogress-segfault.patch diff --git a/php-pecl-uploadprogress.spec b/php-pecl-uploadprogress.spec index 4d8d14b..acf2e8e 100644 --- a/php-pecl-uploadprogress.spec +++ b/php-pecl-uploadprogress.spec @@ -1,6 +1,6 @@ # remirepo spec file for php-pecl-uploadprogress # -# Copyright (c) 2013-2020 Remi Collet +# Copyright (c) 2013-2021 Remi Collet # License: CC-BY-SA # http://creativecommons.org/licenses/by-sa/4.0/ # @@ -22,13 +22,21 @@ Summary: An extension to track progress of a file upload Name: %{?sub_prefix}php-pecl-%{pecl_name} Version: 1.1.3 -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: PHP Group: Development/Languages URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz +# Fix segmentation fault in uploadprogress +# https://github.com/php/pecl-php-uploadprogress/pull/8 +Patch0: %{pecl_name}-arginfo.patch +# Add arginfo to functions +# https://github.com/php/pecl-php-uploadprogress/pull/9 +Patch1: %{pecl_name}-segfault.patch + BuildRequires: %{?dtsprefix}gcc +BuildRequires: make BuildRequires: %{?scl_prefix}php-devel BuildRequires: %{?scl_prefix}php-pear @@ -43,42 +51,26 @@ Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version} Provides: %{?scl_prefix}php-pecl-%{pecl_name} = %{version}-%{release} Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release} -%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} +%if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} # Other third party repo stuff %if "%{php_version}" > "5.5" Obsoletes: php55u-pecl-%{pecl_name} <= %{version} -Obsoletes: php55w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "5.6" Obsoletes: php56u-pecl-%{pecl_name} <= %{version} -Obsoletes: php56w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.0" -Obsoletes: php70u-pecl-%{pecl_name} <= %{version} -Obsoletes: php70w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.1" -Obsoletes: php71u-pecl-%{pecl_name} <= %{version} -Obsoletes: php71w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.2" -Obsoletes: php72u-pecl-%{pecl_name} <= %{version} -Obsoletes: php72w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.3" Obsoletes: php73-pecl-%{pecl_name} <= %{version} -Obsoletes: php73w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.4" Obsoletes: php74-pecl-%{pecl_name} <= %{version} -Obsoletes: php74w-pecl-%{pecl_name} <= %{version} %endif +%if "%{php_version}" > "8.0" +Obsoletes: php80-pecl-%{pecl_name} <= %{version} +%endif +%if "%{php_version}" > "8.1" +Obsoletes: php81-pecl-%{pecl_name} <= %{version} %endif - -%if 0%{?fedora} < 20 && 0%{?rhel} < 7 -# Filter shared private -%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$} -%{?filter_setup} %endif @@ -100,6 +92,8 @@ mv %{pecl_name}-%{version} NTS %{?_licensedir:sed -e '/LICENSE/s/role="doc"/role="src"/' -i package.xml} cd NTS +%patch0 -p1 -b .pr8 +%patch1 -p1 -b .pr9 # Sanity check, really often broken extver=$(sed -n '/#define PHP_UPLOADPROGRESS_VERSION/{s/.* "//;s/".*$//;p}' php_uploadprogress.h) @@ -221,6 +215,12 @@ cd ../ZTS %changelog +* Thu Jul 22 2021 Remi Collet - 1.1.3-2 +- Fix segmentation fault in uploadprogress, patch from + https://github.com/php/pecl-php-uploadprogress/pull/8 +- Add arginfo to functions, patch from + https://github.com/php/pecl-php-uploadprogress/pull/9 + * Wed Jan 29 2020 Remi Collet - 1.1.3-1 - update to 1.1.3 diff --git a/uploadprogress-arginfo.patch b/uploadprogress-arginfo.patch new file mode 100644 index 0000000..81cf86c --- /dev/null +++ b/uploadprogress-arginfo.patch @@ -0,0 +1,40 @@ +From f14654d30953e4b699bf25a244923bbadc55f4f9 Mon Sep 17 00:00:00 2001 +From: Andy Postnikov +Date: Fri, 21 Aug 2020 07:06:27 +0300 +Subject: [PATCH 1/3] Add arginfo to functions + +--- + uploadprogress.c | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/uploadprogress.c b/uploadprogress.c +index 6f72a92..52b313d 100644 +--- a/uploadprogress.c ++++ b/uploadprogress.c +@@ -29,10 +29,22 @@ + #define TMPDIR "/tmp" + #endif + ++/* {{{ argument information */ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_uploadprogress_get_info, 0, 0, 1) ++ ZEND_ARG_TYPE_INFO(0, identifier, IS_STRING, 0) ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_uploadprogress_get_contents, 0, 0, 2) ++ ZEND_ARG_TYPE_INFO(0, identifier, IS_STRING, 0) ++ ZEND_ARG_TYPE_INFO(0, fieldname, IS_STRING, 0) ++ ZEND_ARG_TYPE_INFO(0, maxlen, IS_LONG, 1) ++ZEND_END_ARG_INFO() ++/* }}} */ ++ + /* {{{ uploadprogress_functions[] */ + zend_function_entry uploadprogress_functions[] = { +- PHP_FE(uploadprogress_get_info, NULL) +- PHP_FE(uploadprogress_get_contents, NULL) ++ PHP_FE(uploadprogress_get_info, arginfo_uploadprogress_get_info) ++ PHP_FE(uploadprogress_get_contents, arginfo_uploadprogress_get_contents) + { NULL, NULL, NULL } + }; + /* }}} */ + + diff --git a/uploadprogress-segfault.patch b/uploadprogress-segfault.patch new file mode 100644 index 0000000..6e15157 --- /dev/null +++ b/uploadprogress-segfault.patch @@ -0,0 +1,66 @@ +From b0e5f122b45ddbf7d7475b927e148d6dd5bf3c86 Mon Sep 17 00:00:00 2001 +From: "Christoph M. Becker" +Date: Fri, 30 Apr 2021 17:46:07 +0200 +Subject: [PATCH] Fix #79584: Segmentation fault in uploadprogress 1.1.0 and up + +--- + uploadprogress.c | 18 ++++++++---------- + 1 file changed, 8 insertions(+), 10 deletions(-) + +diff --git a/uploadprogress.c b/uploadprogress.c +index 6f72a92..ca3f17b 100644 +--- a/uploadprogress.c ++++ b/uploadprogress.c +@@ -105,30 +105,23 @@ static int uploadprogress_php_rfc1867_file(unsigned int event, void *event_data + } + + if (strcmp(e_data->name, "UPLOAD_IDENTIFIER") == 0) { +- char **upload_id; + char *template = INI_STR("uploadprogress.file.filename_template"); + + if (strcmp(template, "") == 0) { + return FAILURE; + } + +- upload_id = emalloc(strlen(*e_data->value) + 1); +- strcpy(*upload_id, *e_data->value); +- +- progress->upload_id = *upload_id; ++ progress->upload_id = emalloc(strlen(*e_data->value) + 1); ++ strcpy(progress->upload_id, *e_data->value); + progress->time_last = time(NULL); + progress->speed_average = 0; + progress->speed_last = 0; + progress->bytes_uploaded = read_bytes; + progress->files_uploaded = 0; + progress->est_sec = 0; +- progress->identifier = uploadprogress_mk_filename(*upload_id, template); ++ progress->identifier = uploadprogress_mk_filename(progress->upload_id, template); + progress->identifier_tmp = emalloc(strlen( progress->identifier) + 4); + sprintf(progress->identifier_tmp, "%s.wr", progress->identifier); +- +- if (upload_id) { +- efree(upload_id); +- } + } + } + +@@ -198,6 +191,7 @@ static int uploadprogress_php_rfc1867_file(unsigned int event, void *event_data + } + } else if (event == MULTIPART_EVENT_END) { + VCWD_UNLINK(progress->identifier); ++ efree(progress->upload_id); + efree(progress->identifier); + efree(progress->identifier_tmp); + efree(progress); +@@ -264,6 +258,10 @@ static int uploadprogress_php_rfc1867_file(unsigned int event, void *event_data + efree(progress->identifier); + } + ++ if (progress->upload_id) { ++ efree(progress->upload_id); ++ } ++ + if (progress->identifier_tmp) { + efree(progress->identifier_tmp); + } -- cgit