From 615e9e8b22b3cd93f35c7dca7d01dbfe2c1c8924 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 19 Nov 2014 21:25:33 +1100 Subject: [PATCH] Handle read and write_length functions receiving an invalidated fd --- src/libckpool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libckpool.c b/src/libckpool.c index 747ac02d..860b537e 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -728,6 +728,8 @@ int read_length(int sockd, void *buf, int len) LOGWARNING("Invalid read length of %d requested in read_length", len); return -1; } + if (unlikely(sockd < 0)) + return -1; while (len) { ret = recv(sockd, buf + ofs, len, MSG_WAITALL); if (unlikely(ret < 1)) @@ -803,6 +805,8 @@ int write_length(int sockd, const void *buf, int len) LOGWARNING("Invalid write length of %d requested in write_length", len); return -1; } + if (unlikely(sockd < 0)) + return -1; while (len) { ret = write(sockd, buf + ofs, len); if (unlikely(ret < 0))