From: Hanumanth Reddy Pothula <hpothula@marvell.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Jerin Jacob <jerinj@marvell.com>, "dev@dpdk.org" <dev@dpdk.org>,
Harman Kalra <hkalra@marvell.com>
Subject: RE: [EXTERNAL] Re: [PATCH v2 1/1] event/octeontx: resolve possible integer overflow
Date: Wed, 23 Oct 2024 20:29:32 +0000 [thread overview]
Message-ID: <PH0PR18MB475099C23E19F0C79090AC4ACB4D2@PH0PR18MB4750.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20241023091613.545d03d7@hermes.local>
[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]
From: Stephen Hemminger <stephen@networkplumber.org>
Sent: Wednesday, October 23, 2024 9:46 PM
To: Hanumanth Reddy Pothula <hpothula@marvell.com>
Cc: Jerin Jacob <jerinj@marvell.com>; dev@dpdk.org; Harman Kalra <hkalra@marvell.com>
Subject: [EXTERNAL] Re: [PATCH v2 1/1] event/octeontx: resolve possible integer overflow
On Wed, 23 Oct 2024 12: 45: 46 +0530 Hanumanth Pothula <hpothula@ marvell. com> wrote: > static int > -ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque) > +ssovf_parsekv(const char *key, const char *value,
On Wed, 23 Oct 2024 12:45:46 +0530
Hanumanth Pothula <hpothula@marvell.com<mailto:hpothula@marvell.com>> wrote:
> static int
> -ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque)
> +ssovf_parsekv(const char *key, const char *value, void *opaque)
> {
> - int *flag = opaque;
> - *flag = !!atoi(value);
> + uint8_t *flag = opaque;
> + uint64_t v;
> + char *end;
> +
> + errno = 0;
> + v = (uint8_t)strtoul(value, &end, 0);
Cast will cause truncation of large values.
Maybe:
v = strtoul(value, &end, 0);
if (errno != 0 || value == end || *end != '\0' || v > UINT8_MAX) {
...
Thanks for the review/comment.
Here, the value can only be ‘0’ or ‘1’, so truncation won’t be an issue.
> + if ((errno != 0) || (value == end) || *end != '\0') {
> + ssovf_log_err("invalid %s value %s", key, value);
> + return -EINVAL;
> + }
> +
> + *flag = !!v;
> return 0;
> }
[-- Attachment #2: Type: text/html, Size: 8897 bytes --]
next prev parent reply other threads:[~2024-10-23 20:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 7:59 [PATCH] " Hanumanth Pothula
2024-10-18 16:36 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula
2024-10-18 17:35 ` Stephen Hemminger
2024-10-23 7:15 ` [PATCH v2 1/1] " Hanumanth Pothula
2024-10-23 16:16 ` Stephen Hemminger
2024-10-23 20:29 ` Hanumanth Reddy Pothula [this message]
2024-10-24 3:55 ` [PATCH v3 " Hanumanth Pothula
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=PH0PR18MB475099C23E19F0C79090AC4ACB4D2@PH0PR18MB4750.namprd18.prod.outlook.com \
--to=hpothula@marvell.com \
--cc=dev@dpdk.org \
--cc=hkalra@marvell.com \
--cc=jerinj@marvell.com \
--cc=stephen@networkplumber.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).