We could allow it but it's undefined behaviour in the standard and in some
of our driver code, so force a nice clear error.
uint8_t flag;
if (!nbytes)
- return 0;
+ return 0;
+
+ if ((ssize_t)nbytes < 0) {
+ udata.u_error = EINVAL;
+ return -1;
+ }
if (!valaddr(buf, nbytes))
return -1;
uint8_t flag;
if (!nbytes)
- return 0;
+ return 0;
+
+ if ((ssize_t)nbytes < 0) {
+ udata.u_error = EINVAL;
+ return -1;
+ }
if (!valaddr(buf, nbytes))
return -1;