[PATCH v2 08/13] libdpkg: check for write errors during decompression
An unnoticed write error is unlikely to cause major problems,
since the process on the other end still has a chance to notice
the mangled stream. But it is worth fixing, especially because
the writing end can give a better error message.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
lib/dpkg/compression.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/dpkg/compression.c b/lib/dpkg/compression.c
index 821c0a4..f901867 100644
--- a/lib/dpkg/compression.c
+++ b/lib/dpkg/compression.c
@@ -44,6 +44,8 @@ fd_fd_filter(int fd_in, int fd_out,
zFile zfile = zdopen(fd_in, "r"); \
\
while ((actualread = zread(zfile, buffer, sizeof(buffer)))) { \
+ int actualwrite; \
+ \
if (actualread < 0) { \
int err = 0; \
const char *errmsg = zerror(zfile, &err); \
@@ -53,7 +55,11 @@ fd_fd_filter(int fd_in, int fd_out,
ohshit(_("%s: internal " format " error: %s: %s"), \
desc, "read", errmsg); \
} \
- write(fd_out, buffer, actualread); \
+ \
+ actualwrite = write(fd_out, buffer, actualread); \
+ if (actualwrite != actualread) \
+ ohshite(_("%s: internal " format " error: %s"), \
+ desc, "write"); \
} \
exit(0); \
} while(0)
--
1.6.5.rc1.199.g596ec
Reply to: