commit:     5c1e46228c4d82bd7ce24d740b11622d31ec8291
Author:     Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 12 07:48:05 2020 +0000
Commit:     Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
CommitDate: Sun Jul 12 08:20:47 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5c1e4622

net-proxy/privoxy: fix problems found by gcc

1. Check chdir return value for possible failure in jcc.c

2. Fix possible buffer overflow in gateway.c: strncpy does not
always NULL-terminate string.

Package-Manager: Portage-2.3.99, Repoman-2.3.22
Signed-off-by: Andrew Savchenko <bircoph <AT> gentoo.org>

 net-proxy/privoxy/files/privoxy-3.0.28-chdir.patch        | 15 +++++++++++++++
 .../privoxy/files/privoxy-3.0.28-null-termination.patch   | 13 +++++++++++++
 net-proxy/privoxy/privoxy-3.0.28.ebuild                   |  2 ++
 3 files changed, 30 insertions(+)

diff --git a/net-proxy/privoxy/files/privoxy-3.0.28-chdir.patch 
b/net-proxy/privoxy/files/privoxy-3.0.28-chdir.patch
new file mode 100644
index 00000000000..66d14a9fc3c
--- /dev/null
+++ b/net-proxy/privoxy/files/privoxy-3.0.28-chdir.patch
@@ -0,0 +1,15 @@
+diff '--color=auto' -Naurd privoxy-3.0.28-stable.orig/jcc.c 
privoxy-3.0.28-stable/jcc.c
+--- privoxy-3.0.28-stable.orig/jcc.c   2018-12-30 21:40:13.000000000 +0300
++++ privoxy-3.0.28-stable/jcc.c        2020-07-11 14:43:39.851143843 +0300
+@@ -4013,7 +4013,10 @@
+       }
+ #endif
+ 
+-      chdir("/");
++      if (chdir("/"))
++      {
++         log_error(LOG_LEVEL_FATAL, "Cannot chdir /");
++      }
+ 
+    } /* -END- if (daemon_mode) */
+ 

diff --git a/net-proxy/privoxy/files/privoxy-3.0.28-null-termination.patch 
b/net-proxy/privoxy/files/privoxy-3.0.28-null-termination.patch
new file mode 100644
index 00000000000..295b739a05f
--- /dev/null
+++ b/net-proxy/privoxy/files/privoxy-3.0.28-null-termination.patch
@@ -0,0 +1,13 @@
+diff '--color=auto' -Naurd privoxy-3.0.28-stable.orig/gateway.c 
privoxy-3.0.28-stable/gateway.c
+--- privoxy-3.0.28-stable.orig/gateway.c       2018-12-30 21:40:13.000000000 
+0300
++++ privoxy-3.0.28-stable/gateway.c    2020-07-11 14:55:15.442676106 +0300
+@@ -1103,7 +1103,8 @@
+    cbuf[client_pos++] = (char)(hostlen & 0xffu);
+    assert(sizeof(cbuf) - client_pos > (size_t)255);
+    /* Using strncpy because we really want the nul byte padding. */
+-   strncpy(cbuf + client_pos, target_host, sizeof(cbuf) - client_pos);
++   strncpy(cbuf + client_pos, target_host, sizeof(cbuf) - client_pos - 1);
++   cbuf[sizeof(cbuf)-1] = 0;
+    client_pos += (hostlen & 0xffu);
+    cbuf[client_pos++] = (char)((target_port >> 8) & 0xff);
+    cbuf[client_pos++] = (char)((target_port     ) & 0xff);

diff --git a/net-proxy/privoxy/privoxy-3.0.28.ebuild 
b/net-proxy/privoxy/privoxy-3.0.28.ebuild
index efb5ce555c4..8c973414546 100644
--- a/net-proxy/privoxy/privoxy-3.0.28.ebuild
+++ b/net-proxy/privoxy/privoxy-3.0.28.ebuild
@@ -43,6 +43,8 @@ S="${WORKDIR}/${P%_*}-${PRIVOXY_STATUS}"
 
 PATCHES=(
        "${FILESDIR}"/${PN}-3.0.19-gentoo.patch
+       "${FILESDIR}"/${P}-chdir.patch
+       "${FILESDIR}"/${P}-null-termination.patch
 )
 
 pkg_pretend() {

Reply via email to