From ec9e13345f3f433f3693891864cf794206cdd057 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 15 Jun 2018 09:10:48 -0600 Subject: [PATCH] client: check return of dup(2) If dup(2) fails, we can't pass it to fdopen. Fixes: b4f5e72f1383 ("client: parse env variables before sending job-file contents to server") Signed-off-by: Jens Axboe --- client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client.c b/client.c index 60f7c6ab..611ee2f5 100644 --- a/client.c +++ b/client.c @@ -123,8 +123,13 @@ static int read_ini_data(int fd, void *data, size_t size) char *p = data; int ret = 0; FILE *fp; + int dupfd; - fp = fdopen(dup(fd), "r"); + dupfd = dup(fd); + if (dupfd < 0) + return errno; + + fp = fdopen(dupfd, "r"); if (!fp) return errno; -- 2.25.1