Skip to content

Commit c5f4492

Browse files
esyr-rhrkanagar
authored andcommitted
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 <[email protected]>
1 parent ddcf8a8 commit c5f4492

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/common.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,10 @@ pqos_read(int fd, void *buf, size_t count)
382382
char *byte_ptr = (char *)buf;
383383
ssize_t ret;
384384

385-
if (buf == NULL)
385+
if (buf == NULL) {
386+
errno = EFAULT;
386387
return -1;
388+
}
387389

388390
while (len != 0 && (ret = read(fd, byte_ptr, len)) != 0) {
389391
if (ret == -1) {

0 commit comments

Comments
 (0)