Echo command in busybox writes wrong data after write error
Issue
Echo command built in busybox writes wrong data after write error like
ENOSPC.
Here is a sample script to reproduce this bug:
echo "abcde" > /dev/full
echo "12345" > ./test.txt
The first echo fails with ENOSPC. By the second echo, "12345" is written to test.txt. Therefore the contents of test.txt should be "12345". But actual result is as follows:
[root@localhost test]# ls
run.sh
[root@localhost test]# cat run.sh
echo "abcde" > /dev/full
echo "12345" > ./test.txt
[root@localhost test]# busybox sh run.sh
[root@localhost test]# ls
run.sh test.txt
[root@localhost test]# cat test.txt
abcd12345
The both data "abcde" and "12345" are written to test.txt. Note that this is a problem only for echo command built in shell (ash, msh, and so on), it is not reproduced when echo command is used independently. For example, if you start ash and then run echo command manually, there is no problem.
[root@localhost ~]# busybox ash
# echo "abcde" > /dev/full
abcd#
# echo "12345" > ./test.txt
# cat test.txt
12345
#
Environment
- Red Hat Enterprise Linux (RHEL) 6
- busybox-1.15.1-16.el6_4
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
