diff options
author | Michael Vogt <mvo@debian.org> | 2011-02-02 22:49:41 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2011-02-02 22:49:41 +0100 |
commit | 7c748f4aa1bd47089672353fd1a401d1c5c94723 (patch) | |
tree | 633dd1ca8e7e40cfa25d6227d9859b04bd9d1fad /methods/http.cc | |
parent | a92392501b5981b41da8497a99f5964e2f6075b0 (diff) | |
parent | 7763525dea18d978a1df8eee4a517314ae49ca71 (diff) |
merged from the lp:~mvo/apt/mvo branch
Diffstat (limited to 'methods/http.cc')
-rw-r--r-- | methods/http.cc | 17 |
1 files changed, 13 insertions, 4 deletions
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; |