[PATCH v2] XXXsum: handle binary sums with " " in the path
Denys Vlasenko
vda.linux at googlemail.com
Sat Jan 8 16:16:54 UTC 2022
Applied, thank you
On Fri, Jan 7, 2022 at 2:18 PM Emanuele Giacomelli
<emanuele.giacomelli at gmail.com> wrote:
>
> 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
> ---
> coreutils/md5_sha1_sum.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c
> index 3b389cb6b..d0ea719f3 100644
> --- a/coreutils/md5_sha1_sum.c
> +++ b/coreutils/md5_sha1_sum.c
> @@ -300,12 +300,8 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
> char *filename_ptr;
>
> count_total++;
> - filename_ptr = strstr(line, " ");
> - /* handle format for binary checksums */
> - if (filename_ptr == NULL) {
> - filename_ptr = strstr(line, " *");
> - }
> - if (filename_ptr == NULL) {
> + filename_ptr = strchr(line, ' ');
> + if (filename_ptr == NULL || (filename_ptr[1] != ' ' && filename_ptr[1] != '*')) {
> if (flags & FLAG_WARN) {
> bb_simple_error_msg("invalid format");
> }
> --
> 2.34.1
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list