summaryrefslogtreecommitdiff
path: root/lib/buffer.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-04-17 16:34:25 -0400
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-04-18 12:16:19 -0400
commit6451e84664d5735922c087733f1000a9ebd99504 (patch)
tree577f73d103c859680062e1a14176a61b1c707854 /lib/buffer.c
parent170f8b90ba57c331a6c95e73924bcae8d50220be (diff)
lib: avoid writing to negative fd
Coverity #1399341 Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/buffer.c')
-rw-r--r--lib/buffer.c3
1 files changed, 3 insertions, 0 deletions
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;