From 9e3717a56c8105d1baafbecfd382cb23368b33b9 Mon Sep 17 00:00:00 2001 From: Nelson Ferreira Date: Mon, 10 Oct 2011 21:14:35 -0400 Subject: [PATCH] Coverity fix CID:92 NEGATIVE_RETURNS * lib-src/movemail.c (main): Make sure read was successful before trying to write.. Signed-off-by: Nelson Ferreira --- lib-src/movemail.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib-src/movemail.c b/lib-src/movemail.c index d328c45..5d1e95b 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -418,16 +418,17 @@ int main(int argc, char *argv[]) { char buf[1024]; - + int retries = 3; while (1) { nread = read(indesc, buf, sizeof buf); - if (nread != write(outdesc, buf, nread)) { + if (nread < 0 || + nread != write(outdesc, buf, nread)) { int saved_errno = errno; unlink(outname); errno = saved_errno; pfatal_with_name(outname); } - if (nread < (int)sizeof buf) + if (nread < (int)sizeof(buf)) break; } } -- 2.34.1