mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
b2sum: fix crash with --check and truncated input
* src/md5sum.c (split_3): Ensure we don't walk off the end of the string. * tests/misc/b2sum.sh: Add test cases. Fixes https://bugs.gnu.org/28860
This commit is contained in:
1 parent
f926f7ce0e
commit
cc19f63be3
3 files changed
+10
-1
No files matched your search
@@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
** Bug fixes
|
||||
|
||||
b2sum no longer crashes when processing certain truncated check files.
|
||||
[bug introduced with b2sum coreutils-8.26]
|
||||
|
||||
ptx -S no longer infloops for a pattern which returns zero-length matches.
|
||||
[the bug dates back to the initial implementation]
|
||||
|
||||
|
||||
+2
-1
@@ -430,7 +430,8 @@ split_3 (char *s, size_t s_len,
|
||||
#if HASH_ALGO_BLAKE2
|
||||
/* Terminate and match algorithm name. */
|
||||
char const *algo_name = &s[i - algo_name_len];
|
||||
while (! ISWHITE (s[i]) && s[i] != '-' && s[i] != '(')
|
||||
/* Skip algorithm variants. */
|
||||
while (s[i] && ! ISWHITE (s[i]) && s[i] != '-' && s[i] != '(')
|
||||
++i;
|
||||
bool length_specified = s[i] == '-';
|
||||
bool openssl_format = s[i] == '('; /* and no length_specified */
|
||||
|
||||
@@ -46,4 +46,9 @@ b2sum -l 128 check.vals > out || fail=1
|
||||
printf '%s\n' '796485dd32fe9b754ea5fd6c721271d9 check.vals' > exp
|
||||
compare exp out || fail=1
|
||||
|
||||
# This would segfault from coreutils-8.26 to coreutils-8.28
|
||||
printf '%s\n' 'BLAKE2' 'BLAKE2b' 'BLAKE2-' 'BLAKE2(' 'BLAKE2 (' > crash.check \
|
||||
|| framework_failure_
|
||||
returns_ 1 b2sum -c crash.check || fail=1
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user