From c28f49d43947af652620a147c41ea6137fc1320d Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Tue, 22 May 2007 04:21:00 +0000 Subject: [PATCH] In the error handling path, don't call close(fd) if the error we're handling is that fd = open(foo) is -1. This bug is harmless since close(-1) just returns an error (which the code ignores). Found by: Coverity Prevent(tm) CID: 1503 (in userland test run) --- bin/rcp/rcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c index d36f3bd41811..62d7dafd3306 100644 --- a/bin/rcp/rcp.c +++ b/bin/rcp/rcp.c @@ -403,7 +403,8 @@ syserr: run_err("%s: %s", name, strerror(errno)); if (response() < 0) goto next; if ((bp = allocbuf(&buffer, fd, BUFSIZ)) == NULL) { -next: (void)close(fd); +next: if (fd >= 0) + (void)close(fd); continue; }