summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-11-22 10:54:11 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-11-22 10:54:11 +0100
commite06d6068d7152532ee917783308d911ba2223402 (patch)
treeb8534022f21f3492204678183c2f9bfb3615ea01
parentbdfd00f722fbbffb66497b91488e566e88f1fcbd (diff)
parent08ded4d6a04d28c61a53fe550133b146752badfe (diff)
* methods/http.cc:
- do not hang if Acquire::http::ProxyAutoDetect can not be executed or returns no data (LP: #654393)
-rw-r--r--debian/changelog8
-rw-r--r--methods/http.cc17
2 files changed, 21 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index 5e0b22bfe..a3805f962 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+apt (0.8.9ubuntu3) natty; urgency=low
+
+ * methods/http.cc:
+ - do not hang if Acquire::http::ProxyAutoDetect can not be
+ executed or returns no data (LP: #654393)
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Mon, 22 Nov 2010 10:42:50 +0100
+
apt (0.8.9ubuntu2) natty; urgency=low
* drop apt-changelog, apt-get changelog implements all the
diff --git a/methods/http.cc b/methods/http.cc
index 25e31de9a..dfc1619e3 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -1349,9 +1349,10 @@ bool HttpMethod::AutoDetectProxy()
pid_t Process = ExecFork();
if (Process == 0)
{
+ close(Pipes[0]);
dup2(Pipes[1],STDOUT_FILENO);
SetCloseExec(STDOUT_FILENO,false);
-
+
const char *Args[2];
Args[0] = AutoDetectProxyCmd.c_str();
Args[1] = 0;
@@ -1361,10 +1362,18 @@ bool HttpMethod::AutoDetectProxy()
}
char buf[512];
int InFd = Pipes[0];
- if (read(InFd, buf, sizeof(buf)) < 0)
+ close(Pipes[1]);
+ int res = read(InFd, buf, sizeof(buf));
+ ExecWait(Process, "ProxyAutoDetect", true);
+
+ if (res < 0)
return _error->Errno("read", "Failed to read");
- ExecWait(Process, "ProxyAutoDetect");
-
+ if (res == 0)
+ return _error->Warning("ProxyAutoDetect returned no data");
+
+ // add trailing \0
+ buf[res] = 0;
+
if (Debug)
clog << "auto detect command returned: '" << buf << "'" << endl;