Skip to content

Commit

Permalink
lib: set errno when buf points to NULL in common.c:pqos_read()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
esyr-rh authored and rkanagar committed Oct 9, 2024
1 parent ddcf8a8 commit c5f4492
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c5f4492

Please sign in to comment.