From: Bruce Richardson <bruce.richardson@intel.com>
To: David Marchand <david.marchand@redhat.com>
Cc: Kevin Laatz <kevin.laatz@intel.com>, dev <dev@dpdk.org>,
"Yigit, Ferruh" <ferruh.yigit@intel.com>,
dpdk stable <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] net/ring: fix unchecked return value
Date: Wed, 23 Sep 2020 11:25:32 +0100 [thread overview]
Message-ID: <20200923102532.GA1760@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <CAJFAV8wTe+DbmrYGxzm0Oydu+v1jvwCm8Zhw=Ha9Evdqjt-RVQ@mail.gmail.com>
On Wed, Sep 23, 2020 at 11:43:31AM +0200, David Marchand wrote:
> On Wed, Sep 23, 2020 at 11:39 AM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> > I think a more standard way of checking for trailing chars is to use %n
> > which stores the number of chars processed. Then check that against
> > strlen.
> >
> > For example something like:
> >
> > if (sscanf(value, "%p%n", args, n) != 1 || n != strlen(value)) {
> > /* do error handling */
> > }
> >
>
> The man is a bit scary about %n:
>
> The C standard says: "Execution of a %n directive does not increment
> the assignment count returned at the completion 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.
>
That's not in the man page on my system (Ubuntu 20.04):
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 and does not increase the count returned
by the function. The assignment can be suppressed with the * assignment-
suppression character, but the effect on the return value is undefined.
Therefore %*n conversions should not be used.
next prev parent reply other threads:[~2020-09-23 10:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 17:20 Kevin Laatz
2020-09-23 8:06 ` David Marchand
2020-09-23 9:39 ` Bruce Richardson
2020-09-23 9:43 ` David Marchand
2020-09-23 10:04 ` Kevin Laatz
2020-09-23 10:25 ` Bruce Richardson [this message]
2020-09-25 12:43 ` Ferruh Yigit
2020-10-01 14:14 ` Kevin Laatz
2020-10-01 14:51 ` Ferruh Yigit
2020-10-01 17:09 ` [dpdk-dev] [PATCH v2] " Kevin Laatz
2020-10-12 11:57 ` Ferruh Yigit
2020-10-12 12:45 ` Bruce Richardson
2020-10-12 13:04 ` Ferruh Yigit
2020-10-12 13:11 ` Bruce Richardson
2020-10-13 13:07 ` [dpdk-dev] [PATCH v3] " Kevin Laatz
2020-10-13 17:23 ` Ferruh Yigit
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=20200923102532.GA1760@bricha3-MOBL.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=kevin.laatz@intel.com \
--cc=stable@dpdk.org \
/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;
as well as URLs for NNTP newsgroup(s).