]> git.ipfire.org Git - thirdparty/coreutils.git/commit
shred: fix pattern selection for certain iteration counts
authorPádraig Brady <P@draigBrady.com>
Tue, 7 Jul 2015 00:46:54 +0000 (01:46 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 7 Jul 2015 02:26:58 +0000 (03:26 +0100)
commit5e5d454037df549cc914f45891957181aa3b0a45
treec38655200dc8b738328205b4326f2e129d6b89b1
parentc5ff0d989ffbb16273776092a10553108f269d85
shred: fix pattern selection for certain iteration counts

This was detected in about 25% of runs with gcc -fsanitize=address

  ERROR: AddressSanitizer: global-buffer-overflow on address ...
  READ of size 4 at 0x000000416628 thread T0
    #0 0x40479f in genpattern src/shred.c:782
    #1 0x4050d9 in do_wipefd src/shred.c:921
    #2 0x406203 in wipefile src/shred.c:1175
    #3 0x406b84 in main src/shred.c:1316
    #4 0x7f3454a1ef9f in __libc_start_main (/lib64/libc.so.6+0x1ff9f)
    #5 0x4025d8 (/tmp/coreutils-8.23/src/shred+0x4025d8)
  0x000000416628 is located 56 bytes to the left of
  global variable '*.LC49' from 'src/shred.c' (0x416660) of size 17
  0x000000416628 is located 12 bytes to the right of
  global variable 'patterns' from 'src/shred.c' (0x416540) of size 220
  SUMMARY: AddressSanitizer: global-buffer-overflow src/shred.c:782

* src/shred.c (gen_patterns): Restrict pattern selection
to the K available, which regressed due to v5.92-1462-g65533e1.
* tests/misc/shred-passes.sh: Add a deterministic test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/20998
NEWS
src/shred.c
tests/misc/shred-passes.sh