[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH v2] XXXsum: handle binary sums with " " in the path
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2022-01-08 16:16:54
Message-ID: CAK1hOcPXtATqoiG7G5XBmG_Q4qX-sAv0SoBgKmYe_1NAPj9eeg () mail ! gmail ! com
[Download RAW message or body]

Applied, thank you

On Fri, Jan 7, 2022 at 2:18 PM Emanuele Giacomelli
<emanuele.giacomelli@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@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic