summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2012-10-14 10:52:24 +0200
committerFlorian Festi <ffesti@redhat.com>2012-10-15 15:21:04 +0200
commitb3e24d420f7ab2ff8bc715f4be1643323e0d67da (patch)
tree1321e094dc06764defdcb83fbcb2a6ec03dac1cd
parenta181cb62ecd133b69a52adee5242332c31e28dff (diff)
downloadrpm-4.8.x.tar.gz
Call read() repeatedly to avoid rpm2cpio break on a pipe as input (#802839)rpm-4.8.x
-rw-r--r--rpmio/rpmio.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index 6473d5577..94ff5e25e 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -765,7 +765,22 @@ static const FDIO_t ufdio = &ufdio_s ;
ssize_t timedRead(FD_t fd, void * bufptr, size_t length)
{
- return ufdio->read(fd, bufptr, length);
+ ssize_t already_read =0;
+ ssize_t read = 0;
+ char * cbuf = (char *)(bufptr);
+ while (already_read < length) {
+ read = ufdio->read(fd, cbuf+already_read, length-already_read);
+ if (read == 0) {
+ break;
+ } else if (read < 0) {
+ if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)
+ continue;
+ return read;
+ } else {
+ already_read += read;
+ }
+ }
+ return already_read;
}
/* =============================================================== */