#990268 busybox: incorrect handling of output error for various BusyBox commands

Package:
busybox
Source:
busybox
Description:
Tiny utilities for small and embedded systems
Submitter:
Vincent Lefevre
Date:
2021-06-24 10:15:03 UTC
Severity:
normal
#990268#5
Date:
2021-06-24 10:10:20 UTC
From:
To:
BusyBox does not always handle output error correctly, e.g. with
closed stdout. For instance:

$ busybox sh -c 'exec >&-; for i in echo env pwd; do echo "[$i]" >&2; $i; echo $? >&2; busybox $i; echo $? >&2; done'
[echo]
sh: write error: Bad file descriptor
1
echo: write error: Bad file descriptor
1
[env]
env: write error: Bad file descriptor
125
env: standard output: Bad file descriptor
0
[pwd]
1
255

There are 3 issues here:

1. For echo, in the error message, "sh" is written instead of "echo".
   But the message is OK for "busybox echo".

2. For "busybox env", the exit status is 0 instead of non-zero.
   But the exit status is correct for just "env".

3. For pwd and "busybox pwd", the error message is missing, though it
   is required by POSIX:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pwd.html

Other BusyBox commands might be affected too. To be checked...