From b1965fb70baebc007275b07a1280043d08cefd3f Mon Sep 17 00:00:00 2001 From: baiguo Date: Wed, 3 Jul 2024 19:38:40 +0800 Subject: [PATCH] src/http.c (http_loop): Fix memory leak --- ...src-http.c-http_loop-Fix-memory-leak.patch | 44 +++++++++++++++++++ wget.spec | 9 +++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 backport-src-http.c-http_loop-Fix-memory-leak.patch diff --git a/backport-src-http.c-http_loop-Fix-memory-leak.patch b/backport-src-http.c-http_loop-Fix-memory-leak.patch new file mode 100644 index 0000000..5d9e24e --- /dev/null +++ b/backport-src-http.c-http_loop-Fix-memory-leak.patch @@ -0,0 +1,44 @@ +From 8775506f632f14404e4755dbae679dea07abf12a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tim=20R=C3=BChsen?= +Date: Sun, 9 Jun 2024 20:00:45 +0200 +Subject: * src/http.c (http_loop): Fix memory leak +Reference: https://git.savannah.gnu.org/cgit/wget.git/commit/?id=8775506f632f14404e4755dbae679dea07abf12a + +--- + src/http.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/src/http.c b/src/http.c +index 116a93a..4e4d141 100644 +--- a/src/http.c ++++ b/src/http.c +@@ -4241,7 +4241,7 @@ http_loop (const struct url *u, struct url *original_url, char **newloc, + bool send_head_first = true; + bool force_full_retrieve = false; + +- ++ bool return_local_file; + /* If we are writing to a WARC file: always retrieve the whole file. */ + if (opt.warc_filename != NULL) + force_full_retrieve = true; +@@ -4251,8 +4251,7 @@ http_loop (const struct url *u, struct url *original_url, char **newloc, + assert (local_file == NULL || *local_file == NULL); + + /* Set LOCAL_FILE parameter. */ +- if (local_file && opt.output_document) +- *local_file = HYPHENP (opt.output_document) ? NULL : xstrdup (opt.output_document); ++ return_local_file = local_file && opt.output_document && !HYPHENP (opt.output_document); + + /* Reset NEWLOC parameter. */ + *newloc = NULL; +@@ -4866,7 +4865,6 @@ Remote file exists.\n\n")); + exit: + if ((ret == RETROK || opt.content_on_error) && local_file) + { +- xfree (*local_file); + /* Bugfix: Prevent SIGSEGV when hstat.local_file was left NULL + (i.e. due to opt.content_disposition). */ + if (hstat.local_file) +-- +2.27.0 + diff --git a/wget.spec b/wget.spec index 0349f7a..db19c82 100644 --- a/wget.spec +++ b/wget.spec @@ -1,6 +1,6 @@ Name: wget Version: 1.21.4 -Release: 2 +Release: 3 Summary: A package for retrieving files using HTTP, HTTPS, FTP and FTPS the most widely-used Internet protocols. License: GPL-3.0-or-later AND LGPL-2.1-or-later Url: http://www.gnu.org/software/wget/ @@ -8,6 +8,7 @@ Source: https://ftp.gnu.org/gnu/wget/wget-%{version}.tar.gz Patch0: backport-wget-1.17-path.patch Patch1: backport-CVE-2024-38428.patch +Patch2: backport-src-http.c-http_loop-Fix-memory-leak.patch Provides: webclient bundled(gnulib) BuildRequires: make perl-HTTP-Daemon python3 libuuid-devel perl-podlators libpsl-devel libmetalink-devel @@ -55,6 +56,12 @@ make check %{_infodir}/* %changelog +* Wed Jul 3 2024 baiguo -1.21.4-3 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:src/http.c (http_loop): Fix memory leak + * Sun Jun 16 2024 xuchenchen -1.21.4-2 - Type:CVES - ID:NA -- Gitee