33a815d avoid silent data loss when an input line is 2^31 bytes or longer

Authored and Committed by Vojtech Vitek (V-Teq) 10 years ago
    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>
    
        
file modified
+5 -0