summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-07-11 14:36:39 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2022-07-11 14:36:39 +0200
commit3ad3aa6441ebaf817137051de2b74cb6b4379e7f (patch)
treedbd91fe86a10fac1085a25eca1f4045bfcdf3d8e /coreutils
parent298ac9507bb6cb932162f863c7b9623c0a37dedb (diff)
downloadbusybox-3ad3aa6441ebaf817137051de2b74cb6b4379e7f.tar.gz
shaNNNsum: accept one-space "HASH FILENAME" format for -c, closes 14866
function old new delta md5_sha1_sum_main 496 501 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/md5_sha1_sum.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c
index 0e57673f1..b4bdc262c 100644
--- a/coreutils/md5_sha1_sum.c
+++ b/coreutils/md5_sha1_sum.c
@@ -301,9 +301,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
count_total++;
filename_ptr = strchr(line, ' ');
- if (filename_ptr == NULL
- || (filename_ptr[1] != ' ' && filename_ptr[1] != '*')
- ) {
+ if (!filename_ptr) {
if (flags & FLAG_WARN) {
bb_simple_error_msg("invalid format");
}
@@ -312,8 +310,13 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
free(line);
continue;
}
- *filename_ptr = '\0';
- filename_ptr += 2;
+ *filename_ptr++ = '\0';
+ /* coreutils 9.1 allows "HASH FILENAME" format,
+ * with only one space. Skip the 'correct'
+ * " " or " *" delimiter if it is there:
+ */
+ if (*filename_ptr == ' ' || *filename_ptr == '*')
+ filename_ptr++;
hash_value = hash_file(in_buf, filename_ptr, sha3_width);