From: Matthew Booth <mbooth@redhat.com>
To: linux-lvm@redhat.com
Subject: Re: [linux-lvm] [PATCH] dmsetup: fix sscanf return check
Date: Fri, 24 Aug 2012 09:46:57 +0100 [thread overview]
Message-ID: <50373F81.3080206@redhat.com> (raw)
In-Reply-To: <20120823202737.GA5772@agk-dp.fab.redhat.com>
On 23/08/12 21:27, Alasdair G Kergon wrote:
> On Thu, Aug 23, 2012 at 02:31:02PM +0100, Matthew Booth wrote:
>> - if (sscanf(ptr, "%llu %llu %s %n",
>> - &start, &size, ttype, &n) < 3) {
>> + if (sscanf(ptr, "%llu %llu %s %n", &start, &size, ttype, &n) != 4) {
>
> Did you test this?
No. My git-fu isn't good enough to point that out in the email without
cluttering the commit message with it, but I pointed it out on IRC.
> According to the sscanf man page:
>
> n Nothing is expected; instead, the number of characters consumed
> thus far from the input is stored through the next pointer,
> which must be a pointer to int. This is not a conversion,
> although it can be suppressed with the * assignment-suppression
> character. The C standard says: "Execution of a %n directive
> does not increment the assignment count returned at the comple-
> tion of execution" but the Corrigendum seems to contradict this.
> Probably it is wise not to make any assumptions on the effect of
> %n conversions on the return value.
Thanks for being thorough. I've now made another entry in my mental list
of surprising interfaces :)
Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team
GPG ID: D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
prev parent reply other threads:[~2012-08-24 8:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 13:31 [linux-lvm] [PATCH] dmsetup: fix sscanf return check Matthew Booth
2012-08-23 20:01 ` Mark van Dijk
2012-08-23 20:27 ` Alasdair G Kergon
2012-08-24 8:46 ` Matthew Booth [this message]
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=50373F81.3080206@redhat.com \
--to=mbooth@redhat.com \
--cc=linux-lvm@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.