DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: fengchengwen <fengchengwen@huawei.com>
Cc: <dpdklab@iol.unh.edu>, <test-report@dpdk.org>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: |WARNING| argparse: support range step for corelist parsing
Date: Mon, 19 Oct 2026 09:19:40 -0700	[thread overview]
Message-ID: <20261019091940.5f31d146@phoenix.local> (raw)
In-Reply-To: <73b5e9cd-6789-422a-9679-88693c60352b@huawei.com>

On Mon, 19 Oct 2026 16:36:12 +0800
fengchengwen <fengchengwen@huawei.com> wrote:

> > When `step` is large and `min + step` exceeds `INT32_MAX`, the loop counter wraps around to a negative value, creating an infinite loop. The variables `min` and `max` are `int` (32-bit signed), and `step` is `int32_t`. If a malicious or mistaken user provides input like `"0-100:2147483647"`, the addition `min += step` will overflow after the first iteration.  
> 
> False positive, the:
> 		errno = 0;
> 		idx = strtol(value, &end, 10);
> 		last = end;
> 		if (errno || idx > UINT16_MAX) {
> 			ARGPARSE_LOG(ERR, "argument %s contains a numerical value out of range!",
> 				arg->name_long);
> 			return -EINVAL;
> 		}
> already treat such input as an error.

Since non-negative steps don't make sense, I would use strtoul() instead
and bound it by MAX_LCORE


      reply	other threads:[~2026-10-19 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<20261016093001.9067-1-fengchengwen@huawei.com>
     [not found] ` <20261016100926.06D096051830@postal.iol.unh.edu>
2026-10-19  8:27   ` |WARNING| argparse: support range step for corelist parsing fengchengwen
     [not found] ` <20261016101228.123E46051830@postal.iol.unh.edu>
2026-10-19  8:36   ` fengchengwen
2026-10-19 16:19     ` Stephen Hemminger [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=20261019091940.5f31d146@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=dpdklab@iol.unh.edu \
    --cc=fengchengwen@huawei.com \
    --cc=test-report@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