diff options
author | Emanuele Giacomelli <emanuele.giacomelli@gmail.com> | 2022-01-07 14:17:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-08 17:16:00 +0100 |
commit | 84a1305888ffcd0f4e47cfc4c6fc57918b97bdda (patch) | |
tree | fcc31a87ebeaf5cfb8db55938f9c504b46012dd7 /coreutils/md5_sha1_sum.c | |
parent | e7ff29402d23e1c265769dbe809cf2d329a75ec2 (diff) | |
download | busybox-w32-84a1305888ffcd0f4e47cfc4c6fc57918b97bdda.tar.gz busybox-w32-84a1305888ffcd0f4e47cfc4c6fc57918b97bdda.tar.bz2 busybox-w32-84a1305888ffcd0f4e47cfc4c6fc57918b97bdda.zip |
XXXsum: handle binary sums with " " in the path
If a line specifies a binary checksum whose path contains two adjacent
spaces, when checking digests with -c the two spaces will be used as the
separator between the digest and the pathname instead of " *", as shown:
$ echo foo > "/tmp/two spaces"
$ md5sum -b "/tmp/two spaces" # This is GNU md5sum
d3b07384d113edec49eaa6238ad5ff00 */tmp/two spaces
$ md5sum -b "/tmp/two spaces" | ./busybox md5sum -c
md5sum: can't open 'spaces': No such file or directory
spaces: FAILED
md5sum: WARNING: 1 of 1 computed checksums did NOT match
function old new delta
md5_sha1_sum_main 503 496 -7
Signed-off-by: Emanuele Giacomelli <emanuele.giacomelli@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/md5_sha1_sum.c')
-rw-r--r-- | coreutils/md5_sha1_sum.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 3b389cb6b..0e57673f1 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c | |||
@@ -300,12 +300,10 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv) | |||
300 | char *filename_ptr; | 300 | char *filename_ptr; |
301 | 301 | ||
302 | count_total++; | 302 | count_total++; |
303 | filename_ptr = strstr(line, " "); | 303 | filename_ptr = strchr(line, ' '); |
304 | /* handle format for binary checksums */ | 304 | if (filename_ptr == NULL |
305 | if (filename_ptr == NULL) { | 305 | || (filename_ptr[1] != ' ' && filename_ptr[1] != '*') |
306 | filename_ptr = strstr(line, " *"); | 306 | ) { |
307 | } | ||
308 | if (filename_ptr == NULL) { | ||
309 | if (flags & FLAG_WARN) { | 307 | if (flags & FLAG_WARN) { |
310 | bb_simple_error_msg("invalid format"); | 308 | bb_simple_error_msg("invalid format"); |
311 | } | 309 | } |