From 6451e84664d5735922c087733f1000a9ebd99504 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 17 Apr 2018 16:34:25 -0400 Subject: [PATCH] lib: avoid writing to negative fd Coverity #1399341 Signed-off-by: Quentin Young --- lib/buffer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/buffer.c b/lib/buffer.c index 03202f1253..b573981c1b 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -429,6 +429,9 @@ in one shot. */ size_t iovcnt = 0; size_t nbyte = 0; + if (fd < 0) + return BUFFER_ERROR; + for (d = b->head; d && (iovcnt < MAX_CHUNKS) && (nbyte < MAX_FLUSH); d = d->next, iovcnt++) { iov[iovcnt].iov_base = d->data + d->sp; -- 2.39.5