Calling "socketpair" with a readonly varname errors out, but still opens a...
Enhancement library for Unix shells
Brought to you by:
tetsujin
If socketpair is called with the name of a readonly variable as its argument, the call to socketpair fails with an error message (as it should), but it still opens a socketpair.
In Bash:
$ declare -r x=readonly
$ socketpair x
bash: x: readonly variable
$ ls -l /proc/$$/fd/
total 0
...
lrwx------ 1 tetsujin tetsujin 64 Jul 7 00:50 14 -> socket:[285832]
lrwx------ 1 tetsujin tetsujin 64 Jul 7 00:50 15 -> socket:[285833]
...
$ echo $x
readonly
It is likely that recvmsg suffers from similar issues, as the whole operation is performed before any variable checking is performed.
Acceptance Criteria
If socketpair cannot store its data in the provided variable, the side-effect of opening the socketpair should be prevented or undone.
recvmsg should likewise not extract data from the socket if it is unable to store it in the target variables