From: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [libnftables PATCH] utils: fix error path for nft_strtoi
Date: Mon, 19 Aug 2013 14:37:30 +0200 [thread overview]
Message-ID: <20130819123729.21346.17925.stgit@nfdev.cica.es> (raw)
If the return of nft_get_value() is not evaluated, we don't know if the parsed
value is between the limits of his type.
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
0 files changed
diff --git a/src/utils.c b/src/utils.c
index 848eba9..9a0bcfe 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -103,6 +103,7 @@ int nft_get_value(enum nft_type type, void *val, void *out)
int nft_strtoi(const char *string, int base, void *out, enum nft_type type)
{
+ int ret;
int64_t sval = 0;
uint64_t uval = -1;
char *endptr;
@@ -113,14 +114,14 @@ int nft_strtoi(const char *string, int base, void *out, enum nft_type type)
case NFT_TYPE_U32:
case NFT_TYPE_U64:
uval = strtoll(string, &endptr, base);
- nft_get_value(type, &uval, out);
+ ret = nft_get_value(type, &uval, out);
break;
case NFT_TYPE_S8:
case NFT_TYPE_S16:
case NFT_TYPE_S32:
case NFT_TYPE_S64:
sval = strtoull(string, &endptr, base);
- nft_get_value(type, &sval, out);
+ ret = nft_get_value(type, &sval, out);
break;
default:
errno = EINVAL;
@@ -132,7 +133,7 @@ int nft_strtoi(const char *string, int base, void *out, enum nft_type type)
return -1;
}
- return 0;
+ return ret;
}
const char *nft_verdict2str(uint32_t verdict)
next reply other threads:[~2013-08-19 12:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-19 12:37 Arturo Borrero Gonzalez [this message]
2013-08-20 11:09 ` [libnftables PATCH] utils: fix error path for nft_strtoi Pablo Neira Ayuso
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=20130819123729.21346.17925.stgit@nfdev.cica.es \
--to=arturo.borrero.glez@gmail.com \
--cc=netfilter-devel@vger.kernel.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 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.