From: Peter Mamonov <pmamonov@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: command: hashsum: md5sum reports wrong sum for the file named 4k.bin
Date: Fri, 5 Jan 2018 21:17:30 +0300 [thread overview]
Message-ID: <20180105181730.q65oevjnuixvn5k2@localhost> (raw)
In-Reply-To: <20180105114419.pfb3ouxfogen4y6f@pengutronix.de>
On Fri, Jan 05, 2018 at 12:44:19PM +0100, Sascha Hauer wrote:
> Hi Peter,
>
> On Thu, Dec 21, 2017 at 01:48:11PM +0300, Peter Mamonov wrote:
> > On Wed, Dec 20, 2017 at 01:48:14PM +0300, Peter Mamonov wrote:
> > > Hi,
> > >
> > > The md5sum command reports wrong sum for a file named 4k.bin and, I guess, for
> > > other files named alike. Here are the commands to reproduce the bug:
> >
> > The problem lays in __do_digest() function:
> > - it initializes variables `start` and `size` at commands/digest.c:38
> > - then it calls parse_area_spec(*argv, &start, &size) at commands/digest.c:42
> > - parse_area_spec() returns error as it should, however it changes the value
> > of the `start` at lib/misc.c:87.
> > - this causes digest algo to skip leading 4k of the data from the file.
> >
> > I'm not quite sure what is the best solution:
> > - prevent parse_area_spec() from setting start if it fails?
> > - reinitialize start/size after unsuccessfull call to parse_area_spec()?
>
> preventing parse_area_spec() from modifying start and size if it fails
> seems like a good idea.
>
> However, this doesn't solve the problem, does it? parse_area_spec()
> only fails because the dot in 4k.bin is not valid, but if you name
> the file only '4k' then parse_area_spec() won't fail.
> The problem is that we cannot know whether '4k' is a file or an area.
You are right. However, there is no ambiguity in the "4k.bin" and similar
cases, so we can fix at least this obvious problem.
Regards,
Peter
>
> Right now I have no good idea how to make the command nonambiguous,
> but this will require an incompatible change to the commands arguments.
>
> Sascha
>
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-01-05 18:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 10:48 Peter Mamonov
2017-12-21 10:48 ` Peter Mamonov
2018-01-05 11:44 ` Sascha Hauer
2018-01-05 18:17 ` Peter Mamonov [this message]
2018-01-09 11:10 ` Sascha Hauer
2018-01-09 14:21 ` [PATCH] lib: parse_area_spec: don't modify *start and *size values if parse failed Peter Mamonov
2018-01-11 8:15 ` Sascha Hauer
2018-01-11 17:28 ` Peter Mamonov
2018-01-15 11:32 ` [PATCH v2 1/3] lib: parse_area_spec: don't modify *start value " Peter Mamonov
2018-01-15 11:32 ` [PATCH v2 2/3] lib: parse_area_spec: part of the area spec after -/+ should start with a digit Peter Mamonov
2018-01-15 11:32 ` [PATCH v2 3/3] lib: parse_area_spec: no extra symbols after area spec are allowed except for spaces Peter Mamonov
2018-01-17 8:11 ` [PATCH v2 1/3] lib: parse_area_spec: don't modify *start value if parse failed Sascha Hauer
2018-01-17 9:31 ` Peter Mamonov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180105181730.q65oevjnuixvn5k2@localhost \
--to=pmamonov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox