From: Jens Axboe Date: Fri, 15 Jun 2018 15:10:48 +0000 (-0600) Subject: client: check return of dup(2) X-Git-Tag: fio-3.8~29 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ec9e13345f3f433f3693891864cf794206cdd057;hp=b4f5e72f1383499439c45acee627c022f06b6825 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 --- 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;