All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alasdair G Kergon <agk@redhat.com>
To: Matthew Booth <mbooth@redhat.com>
Cc: linux-lvm@redhat.com
Subject: Re: [linux-lvm] [PATCH] dmsetup: fix sscanf return check
Date: Thu, 23 Aug 2012 21:27:38 +0100	[thread overview]
Message-ID: <20120823202737.GA5772@agk-dp.fab.redhat.com> (raw)
In-Reply-To: <1345728662-28052-1-git-send-email-mbooth@redhat.com>

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?

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.

Alasdair

  parent reply	other threads:[~2012-08-23 20:27 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 [this message]
2012-08-24  8:46   ` Matthew Booth

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=20120823202737.GA5772@agk-dp.fab.redhat.com \
    --to=agk@redhat.com \
    --cc=linux-lvm@redhat.com \
    --cc=mbooth@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.