Project

General

Profile

Bug #3820

/usr/bin/sed doesn't handle binary files.

Added by Johann Oskarsson over 7 years ago. Updated over 7 years ago.

Status:
Resolved
Priority:
Normal
Category:
cmd - userland programs
Start date:
2013-06-16
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

The "bug" is very simple. Internally, sed uses fgets() to read the lines of the input files. This means embedded zero bytes are completely ignored among other weird behavior when binary files are read in.

It makes /usr/bin/sed completely useless to extract zip contents from an executable python script. Example:

sed -e 1d python-zip-script > python-zip-script.zip

Where python-zip-script is a file with !#/usr/bin/python in the first line, and the rest is a zip packaged python application.

GNU sed handles this just fine.


Files

main.c-getline.diff (1.7 KB) main.c-getline.diff Johann Oskarsson, 2013-06-19 03:07 PM

History

#1

Updated by Johann Oskarsson over 7 years ago

This patch removes the custom fgetln() replacement and uses getline() to read the lines.

#2

Updated by Johann Oskarsson over 7 years ago

  • Assignee set to Johann Oskarsson
  • % Done changed from 10 to 90

The webrev for the final change is here:
http://www.myrkraverk.com/~johann/webrev/illumos/3820-1/

It's been reviewed by Josef 'Jeff' Sipek and Richard Lowe.

#3

Updated by Johann Oskarsson over 7 years ago

  • % Done changed from 90 to 100
#4

Updated by Robert Mustacchi over 7 years ago

Resolved in e3eaa28d3fe8168d8e638eb7030062ea13c13d76.

#5

Updated by Robert Mustacchi over 7 years ago

  • Status changed from In Progress to Resolved
  • Tags deleted (needs-triage)

Also available in: Atom PDF