From 182bb7032151e39d6af6fc34992c7940568b1117 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Fri, 16 Aug 2024 16:11:22 +0200 Subject: [PATCH 5/5] lib: set errno when buf points to NULL in common.c:pqos_read() There is little need for the check, as the first read() call is supposed to fail with EFAULT in case buf is NULL, but if this check is done, it would be nice if it matches the error code the call it wraps. Signed-off-by: Eugene Syromiatnikov --- lib/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/common.c b/lib/common.c index c9688b82f99d..3273c86d16e8 100644 --- a/lib/common.c +++ b/lib/common.c @@ -382,8 +382,10 @@ pqos_read(int fd, void *buf, size_t count) char *byte_ptr = (char *)buf; ssize_t ret; - if (buf == NULL) + if (buf == NULL) { + errno = EFAULT; return -1; + } while (len != 0 && (ret = read(fd, byte_ptr, len)) != 0) { if (ret == -1) { -- 2.28.0