Source: packagekit
Version: 1.0.1-2
Tags: patch upstream

Hi,

Whenever the proxy configuration can not be found in the PackageKit.db
the proxy variables of PkBackendJob are left uninitialized. Moreover,
aptcc's AptIntf::init comes later down on the line and unconditionally
sets http_proxy and ftp_proxy, therefore setting them to whatever the
string processing functions get to read from memory.

The latter seems to have been fixed in 1.0.11, but from a quick look
it appears that the former bug is still present.

This environment is then available all the way to the maintainer
scripts and prevent them from working correctly due to the invalid
values.


Attached patches should fix both problems for 1.0.1-2, and the
pk-transaction-db.c patch applies as-is, with some fuzz,  to 1.0.11.

Cheers,
-- 
Raphael Geissert - Debian Developer
www.debian.org - get.debian.net
Index: packagekit-1.0.1/backends/aptcc/apt-intf.cpp
===================================================================
--- packagekit-1.0.1.orig/backends/aptcc/apt-intf.cpp	2015-12-02 11:51:16.950630140 +0100
+++ packagekit-1.0.1/backends/aptcc/apt-intf.cpp	2015-12-02 11:52:37.969169197 +0100
@@ -88,13 +88,17 @@ bool AptIntf::init()
 
     // set http proxy
     http_proxy = pk_backend_job_get_proxy_http(m_job);
-    setenv("http_proxy", http_proxy, 1);
-    g_free(http_proxy);
+    if (http_proxy != NULL) {
+        setenv("http_proxy", http_proxy, 1);
+        g_free(http_proxy);
+    }
 
     // set ftp proxy
     ftp_proxy = pk_backend_job_get_proxy_ftp(m_job);
-    setenv("ftp_proxy", ftp_proxy, 1);
-    g_free(ftp_proxy);
+    if (ftp_proxy != NULL) {
+        setenv("ftp_proxy", ftp_proxy, 1);
+        g_free(ftp_proxy);
+    }
 
     // Prepare for the restart thing
     if (g_file_test(REBOOT_REQUIRED, G_FILE_TEST_EXISTS)) {
Index: packagekit-1.0.1/src/pk-transaction-db.c
===================================================================
--- packagekit-1.0.1.orig/src/pk-transaction-db.c	2015-12-01 17:34:52.981602037 +0100
+++ packagekit-1.0.1/src/pk-transaction-db.c	2015-12-01 17:35:01.361448251 +0100
@@ -646,13 +646,13 @@ pk_transaction_db_get_proxy (PkTransacti
 		goto out;
 	}
 
+	/* success, even if we got no data */
+	ret = TRUE;
+
 	/* nothing matched */
 	if (!item->set)
 		goto out;
 
-	/* success, even if we got no data */
-	ret = TRUE;
-
 	/* copy data */
 	if (proxy_http != NULL)
 		*proxy_http = g_strdup (item->proxy_http);

Reply via email to