Fix mismatched net[]/delete[] in proxy.cpp

This commit is contained in:
yu_boyun 2021-03-29 17:11:24 +08:00
parent 0e6f65637c
commit d93e8e12c2
2 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,56 @@
From 83cee994952ceb2ff4c818de78f7758c75549e3d Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@gnome.org>
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<wpad_extension*> wpads = this->mm.get_extensions<wpad_extension>();
for (vector<wpad_extension*>::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<string> &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

View File

@ -1,6 +1,6 @@
Name: libproxy
Version: 0.4.15
Release: 15
Release: 16
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: backport-Fix-mismatched-new-delete-in-proxy.cpp.patch
BuildRequires: cmake >= 2.6.0 gcc-c++
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 <yuboyun@huawei.com> - 0.4.15-16
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:Fix mismatched new[]/delete[] in proxy.cpp
* Mon Nov 9 gaihuiying <gaihuiying1@huawei.com> - 0.4.15-15
- Type:bugfix
- Id:NA