[Bug 11871] New: Bug in sed addressing (<addr>,+N)

bugzilla at busybox.net bugzilla at busybox.net
Mon May 13 06:44:53 UTC 2019


https://bugs.busybox.net/show_bug.cgi?id=11871

            Bug ID: 11871
           Summary: Bug in sed addressing (<addr>,+N)
           Product: Busybox
           Version: 1.30.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: vit.lapka at racom.eu
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

Created attachment 8036
  --> https://bugs.busybox.net/attachment.cgi?id=8036&action=edit
Patch that seems to fix the issue

Hello,
  it seems I have found a bug in busybox implementation of sed utility (version
1.29.3, also in 1.30.1). When using row addressing in sed command in format
<addr1>,+N (i.e. apply to N rows following the match of <addr1>), it seems that
following rows are processed only for the first match. For following matches,
only the first row (matching <addr1>) is processed.
  Example:
- test file:
AAA
    BBB1
CCC
CCC
AAA
    BBB2
AAA
    BBB3
- command: sed -n '/AAA/,+1 p' file
- expected result (GNU sed):
AAA
    BBB1
AAA
    BBB2
AAA
    BBB3
- busybox sed:
AAA
    BBB1
AAA
AAA
  I have just quickly inspected the code and it seems that index of the last
line for multiline match is overwritten with computed value relative to the
first match and not reset/recomputed for further matches. I created a patch
that seems to fix the issue, however I am not entirely confident it is a
correct and clean solution.
With regards,
  Vit Lapka

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list