From 97b3bd0155376ea1159a4b54ca995c91f6c3fb4d Mon Sep 17 00:00:00 2001 From: yu_boyun <1215979730@qq.com> Date: Mon, 29 Mar 2021 16:27:41 +0800 Subject: [PATCH] Fix mismatched new[]/delete[] in proxy.cpp --- ...x-mismatched-new-delete-in-proxy.cpp.patch | 56 +++++++++++++++++++ libproxy.spec | 9 ++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 0001-Fix-mismatched-new-delete-in-proxy.cpp.patch diff --git a/0001-Fix-mismatched-new-delete-in-proxy.cpp.patch b/0001-Fix-mismatched-new-delete-in-proxy.cpp.patch new file mode 100644 index 0000000..9c01c65 --- /dev/null +++ b/0001-Fix-mismatched-new-delete-in-proxy.cpp.patch @@ -0,0 +1,56 @@ +From 83cee994952ceb2ff4c818de78f7758c75549e3d Mon Sep 17 00:00:00 2001 +From: Michael Catanzaro +Date: Thu, 10 Sep 2020 14:57:37 -0500 +Subject: [PATCH] Fix mismatched new[]/delete[] in proxy.cpp + +Using the wrong delete operator is undefined behavior. + +All this manual new/delete really ought to be replaced by +std::unique_ptr, but this will suffice for now. +--- + libproxy/proxy.cpp | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/libproxy/proxy.cpp b/libproxy/proxy.cpp +index 2d01d53..72d0039 100644 +--- a/libproxy/proxy.cpp ++++ b/libproxy/proxy.cpp +@@ -244,7 +244,7 @@ void proxy_factory::check_network_topology() { + vector wpads = this->mm.get_extensions(); + for (vector::iterator j=wpads.begin() ; j != wpads.end() ; j++) + (*j)->rewind(); +- if (this->pac) delete this->pac; ++ if (this->pac) delete[] this->pac; + this->pac = NULL; + break; + } +@@ -313,7 +313,7 @@ bool proxy_factory::expand_wpad(const url &confurl) + rtv = true; + /* If the config has just changed from PAC to WPAD, clear the PAC */ + if (!this->wpad) { +- if (this->pac) delete this->pac; ++ if (this->pac) delete[] this->pac; + if (this->pacurl) delete this->pacurl; + this->pac = NULL; + this->pacurl = NULL; +@@ -381,7 +381,7 @@ bool proxy_factory::expand_pac(url &confurl) + if (this->pac) { + if (this->pacurl->to_string() != confurl.to_string()) { + delete this->pacurl; +- delete this->pac; ++ delete[] this->pac; + this->pacurl = NULL; + this->pac = NULL; + } +@@ -424,7 +424,7 @@ void proxy_factory::run_pac(url &realurl, const url &confurl, vector &re + + void proxy_factory::clear_cache() { + this->wpad = false; +- if (this->pac) { delete this->pac; this->pac = NULL; } ++ if (this->pac) { delete[] this->pac; this->pac = NULL; } + if (this->pacurl) { delete this->pacurl; this->pacurl = NULL; } + } + +-- +1.8.3.1 + diff --git a/libproxy.spec b/libproxy.spec index ee928c0..949a5db 100644 --- a/libproxy.spec +++ b/libproxy.spec @@ -1,6 +1,6 @@ Name: libproxy Version: 0.4.15 -Release: 14 +Release: 15 Summary: Libproxy is a library that provides automatic proxy configuration management License: LGPLv2+ @@ -15,6 +15,7 @@ Patch1: libproxy-0.4.11-crash.patch Patch2: libproxy-0.4.15-python3738.patch Patch3: libproxy-0.4.15-mozjs52.patch Patch4: Fix-buffer-overflow-when-PAC-is-enabled.patch +Patch5: 0001-Fix-mismatched-new-delete-in-proxy.cpp.patch BuildRequires: cmake >= 2.6.0 gcc-c++ libmodman-devel >= 2.0.1 BuildRequires: pkgconfig(gio-2.0) >= 2.26 pkgconfig(mozjs-52) pkgconfig(libnm) python2-devel python3-devel @@ -123,6 +124,12 @@ make test %{_mandir}/man1/proxy.1* %changelog +* Mon Mar 29 yuboyun - 0.4.15-15 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Fix mismatched new[]/delete[] in proxy.cpp + * Tue Oct 20 hanzhijun - 0.4.15-14 - Type:cves - Id:NA -- Gitee