From 3ca6eaca538d496867ac4e5e9faf2cf51162ad2f Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 31 Mar 2011 14:45:47 +0100 Subject: [PATCH] Don't hang if something goes wrong reading from a tar archive Returning EIO (a small positive integer) as the result of archive_tar_file::read() on an error isn't a good idea, it's indistinguishable from successfully reading a small number of bytes. This causes io_stream::copy() to spin forever if it's reading from an archive stream which terminates unexpectedly early, which can happen on an decompression error. So, return 0 instead 2011-03-31 Jon TURNEY * archive_tar_file.cc (read, peek): Return 0 on an error, not EIO. Signed-off-by: Jon TURNEY --- archive_tar_file.cc | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archive_tar_file.cc b/archive_tar_file.cc index 29a2df7..ed6e515 100644 --- a/archive_tar_file.cc +++ b/archive_tar_file.cc @@ -65,7 +65,7 @@ ssize_t archive_tar_file::read (void *buffer, size_t len) /* unexpected EOF or read error in the tar parent stream */ /* the user can query the parent for the error */ state.lasterr = EIO; - return EIO; + return 0; } } return 0; @@ -96,7 +96,7 @@ ssize_t archive_tar_file::peek (void *buffer, size_t len) /* unexpected EOF or read error in the tar parent stream */ /* the user can query the parent for the error */ state.lasterr = EIO; - return EIO; + return 0; } } return 0; -- 1.7.4