Commit Graph

1 Commits

Author SHA1 Message Date
Vojtech Vitek (V-Teq)
33a815d107 avoid silent data loss when an input line is 2^31 bytes or longer
If one line in a file has length (including newline) of 2^31, then
applying sed -i to that file truncates it to size 0.  I first
noticed it like this: Create a file with line of length 2^31-1
  $ perl -le 'print "v"x(2**31-1)' > k
Then prepend a byte to that line:
  $ sed -i 's/^/v/' k
Surprise!  The file is empty.
* sed/utils.c (ck_getline): Declare "result" to be of type ssize_t,
rather than int, to match the return type of getline.

Upstream 81ce070727b225a1e23e5a48f775811c8a9e7366
by Jim Meyering <meyering@redhat.com>
2011-07-12 16:08:05 +02:00