[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH v2 05/13] libdpkg: fix compress_cat to read/write to arbitrary fds



The compress_cat() code had a hidden assumption that fd_in is 0
and fd_out is 1.  This is a bug waiting to happen.  But luckily,
all callers do use those values, so it is harmless.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 lib/dpkg/compression.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dpkg/compression.c b/lib/dpkg/compression.c
index c80a9b1..f1b6836 100644
--- a/lib/dpkg/compression.c
+++ b/lib/dpkg/compression.c
@@ -70,8 +70,8 @@ fd_fd_filter(int fd_in, int fd_out,
   \
   strncpy(combuf, "w9", sizeof(combuf)); \
   combuf[1] = compression; \
-  zfile = zdopen(1, combuf); \
-  while ((actualread = read(0, buffer, sizeof(buffer))) > 0) { \
+  zfile = zdopen(fd_out, combuf); \
+  while ((actualread = read(fd_in, buffer, sizeof(buffer))) > 0) { \
     if (actualread < 0) { \
       if (errno == EINTR) \
         continue; \
-- 
1.6.5.rc1.199.g596ec


Reply to: