Project

General

Profile

Actions

Bug #3820

closed

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

Added by Johann Oskarsson almost 10 years ago. Updated almost 10 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:
External Bug:

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
Actions #1

Updated by Johann Oskarsson almost 10 years ago

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

Actions #2

Updated by Johann Oskarsson almost 10 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.

Actions #3

Updated by Johann Oskarsson almost 10 years ago

  • % Done changed from 90 to 100
Actions #4

Updated by Robert Mustacchi almost 10 years ago

Resolved in e3eaa28d3fe8168d8e638eb7030062ea13c13d76.

Actions #5

Updated by Robert Mustacchi almost 10 years ago

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

Also available in: Atom PDF