Blame SOURCES/diffutils-3.6-shows_incorrect_data.patch

5004ac
commit ffd63aedad3c0eb08ebb27103e5f242f8732dc0c
5004ac
Author: Paul Eggert <eggert@cs.ucla.edu>
5004ac
Date:   Tue Jul 24 10:18:28 2018 -0700
5004ac
5004ac
    cmp: fix bug in -b diagnostic
5004ac
    
5004ac
    Problem reported by mancha (Bug#32249).
5004ac
    * src/cmp.c (count_newlines): Restore old value of sentinel.
5004ac
    * tests/cmp: Test for the bug.
5004ac
5004ac
diff --git a/src/cmp.c b/src/cmp.c
5004ac
index 04638e3..2811392 100644
5004ac
--- a/src/cmp.c
5004ac
+++ b/src/cmp.c
5004ac
@@ -639,9 +639,11 @@ count_newlines (char *buf, size_t bufsize)
5004ac
   size_t count = 0;
5004ac
   char *p;
5004ac
   char *lim = buf + bufsize;
5004ac
+  char ch = *lim;
5004ac
   *lim = '\n';
5004ac
   for (p = buf; (p = rawmemchr (p, '\n')) != lim; p++)
5004ac
     count++;
5004ac
+  *lim = ch;
5004ac
   return count;
5004ac
 }
5004ac
 
5004ac
diff --git a/tests/cmp b/tests/cmp
5004ac
index 160c1ea..ca0fe5e 100755
5004ac
--- a/tests/cmp
5004ac
+++ b/tests/cmp
5004ac
@@ -208,4 +208,14 @@ done >out1
5004ac
 
5004ac
 compare exp1 out1 || fail=1
5004ac
 
5004ac
+printf 'bad\n' >bad
5004ac
+printf 'bug\n' >bug
5004ac
+echo LC_ALL=C cmp -b bad bug
5004ac
+LC_ALL=C cmp -b bad bug
5004ac
+test $? -eq 1 || fail=1
5004ac
+case `LC_ALL=C cmp -b bad bug` in
5004ac
+  'bad bug differ: byte 2, line 1 is '*' a '*' u') ;;
5004ac
+  *) echo 'expected cmp -b to report a and u'; fail=1;;
5004ac
+esac
5004ac
+
5004ac
 Exit $fail