mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
cksum: fix off-by-1 bug with \r stripping
Problem reported by Jim Meyering (Bug#50611). * src/digest.c (digest_check): When stripping trailing \r, avoid subscript error before start of line.
This commit is contained in:
1 parent
2715aba08a
commit
121f74dfc2
1 file changed
+3
-4
+3
-4
@@ -1070,11 +1070,10 @@ digest_check (char const *checkfile_name)
|
||||
continue;
|
||||
|
||||
/* Remove any trailing newline. */
|
||||
if (line[line_length - 1] == '\n')
|
||||
line[--line_length] = '\0';
|
||||
line_length -= line[line_length - 1] == '\n';
|
||||
/* Remove any trailing carriage return. */
|
||||
if (line[line_length - 1] == '\r')
|
||||
line[--line_length] = '\0';
|
||||
line_length -= line[line_length - (0 < line_length)] == '\r';
|
||||
line[line_length] = '\0';
|
||||
|
||||
if (! (split_3 (line, line_length, &hex_digest, &binary, &filename)
|
||||
&& ! (is_stdin && STREQ (filename, "-"))))
|
||||
|
||||
Reference in new issue
Block a user