From c5f44924ec70c3f6dec054d49bbc74487edc841c Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Fri, 16 Aug 2024 16:11:22 +0200 Subject: [PATCH] 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 c9688b82..3273c86d 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) {