Bug 252551 - POSIX compliance: writev does not return EINVAL when iovcnt == 0
Summary: POSIX compliance: writev does not return EINVAL when iovcnt == 0
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-10 04:28 UTC by Alan Somers
Modified: 2021-01-10 04:50 UTC (History)
1 user (show)

See Also:


Attachments
return EINVAL from writev and friends if iovcnt = 0 (1.96 KB, patch)
2021-01-10 04:45 UTC, Alan Somers
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer 2021-01-10 04:28:56 UTC
POSIX requires that readv and writev return EINVAL when iovcnt == 0.  Our own man pages document that condition as well.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/writev.html
https://pubs.opengroup.org/onlinepubs/9699919799/functions/readv.html

However, we accept iovcnt == 0, do nothing, and return 0.  That's not inherently unreasonable, but it's not POSIX-compliant.  From inspection, OpenBSD and NetBSD do not have this bug, but DragonflyBSD does.
Comment 1 Alan Somers freebsd_committer 2021-01-10 04:45:03 UTC
Created attachment 221435 [details]
return EINVAL from writev and friends if iovcnt = 0
Comment 2 Alan Somers freebsd_committer 2021-01-10 04:50:57 UTC
Actually, on closer inspection POSIX says that writev "may fail", not "shall fail" if iovcnt is out of bounds.  So I guess this isn't a bug after all.