Bug 356111 - busybox sed cuts output at random multiples of 1024
Summary: busybox sed cuts output at random multiples of 1024
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: busybox
Version: rawhide
Hardware: i386
OS: Linux
low
low
Target Milestone: ---
Assignee: Ivana Varekova
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-10-29 01:34 UTC by Hans Ulrich Niedermann
Modified: 2007-11-30 22:12 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-10-31 15:04:41 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Test input (1.28 KB, text/plain)
2007-10-29 23:32 UTC, Hans Ulrich Niedermann
no flags Details
Run both GNU sed and busybox sed on in.txt (260 bytes, text/plain)
2007-10-29 23:33 UTC, Hans Ulrich Niedermann
no flags Details
Add another forgotten output flush (463 bytes, patch)
2007-10-30 14:13 UTC, Hans Ulrich Niedermann
no flags Details | Diff

Description Hans Ulrich Niedermann 2007-10-29 01:34:23 UTC
Description of problem:

  In calls like
    /sbin/busybox sed -n '1,$p' /some/textfile > output.txt
  busybox cuts the output to multiples of 1024 (including 0).
  It seems to be independent of the actual sed command given.

Version-Release number of selected component (if applicable):

  busybox-1.6.1-2.fc8 (/sbin/busybox sed)
  bash-3.2-18.fc8 (calls busybox sed)

How reproducible:

  Every time.

Steps to Reproduce:
1. Find a long text file (e.g. /etc/passwd or /etc/abcde.conf)
2. /sbin/busybox sed -n '1,$p' long.txt > output.txt
3. ls -l long.txt output.txt
4. diff -u long.txt output.txt
  
Actual results:

  output.txt is 0, 1024, 4096, 8192 bytes long, while long.txt is longer.

Expected results:

  For text files, long.txt and output.txt should be equal with '1,$p'.

Additional info:

  Workaround:
    /sbin/busybox sed -n '1,$p' long.txt | cat > output.txt

Comment 1 Ivana Varekova 2007-10-29 14:32:12 UTC
Fixed in busybox-1.7.2-2.fc9.

Comment 2 Hans Ulrich Niedermann 2007-10-29 23:31:25 UTC
Not for all cases. I have locally built and installed busybox-1.7.2-2.fc9 from
Fedora CVS - and ran into problems when trying the next sed expression.

Test case being uploaded as attachments.

Comment 3 Hans Ulrich Niedermann 2007-10-29 23:32:53 UTC
Created attachment 242501 [details]
Test input

Comment 4 Hans Ulrich Niedermann 2007-10-29 23:33:50 UTC
Created attachment 242511 [details]
Run both GNU sed and busybox sed on in.txt

Comment 5 Hans Ulrich Niedermann 2007-10-30 14:13:23 UTC
Created attachment 243411 [details]
Add another forgotten output flush

Together with your busybox-1.7.2-sed.patch, this at fixes all my current use
cases.

I'm not saying this is the general solution. I'd need to completely dive into
that code for that degree of confidence.

I guess upstream should take a look at it.

Comment 6 Ivana Varekova 2007-10-31 15:04:41 UTC
Thanks, this problem is fixed in busybox-1.7.2-3.fc9 but fflush in your patch
was on the wrong place. 
Please if there is still any problem please reopen this bug. 
I contacted busybox upstream with this issue so I hope this problem will be
fixed in some new upstream version too.




Note You need to log in before you can comment on or make changes to this bug.