From: "Holger Eitzenberger" <holger@eitzenberger.org>
To: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org
Subject: [patch 1/6] ipset: turn Set name[] into a const pointer
Date: Mon, 24 Jan 2011 22:36:32 +0100 [thread overview]
Message-ID: <20110124214009.410600508@jonathan.eitzenberger.org> (raw)
In-Reply-To: 20110124213631.195499507@jonathan.eitzenberger.org
[-- Attachment #1: ipset-set_type-name-pointer.diff --]
[-- Type: text/plain, Size: 2005 bytes --]
Also check for the name length.
Note that passing errno values back is not done consistently at
various place, as there are some functions which set errno manually,
others pass -errno back. I use the -errno approach here, as it is
slightly shorter.
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Index: ipset/include/libipset/types.h
===================================================================
--- ipset.orig/include/libipset/types.h
+++ ipset/include/libipset/types.h
@@ -70,7 +70,7 @@ struct ipset_elem {
* but for the readability the full list is supported.
*/
struct ipset_type {
- char name[IPSET_MAXNAMELEN]; /* type name */
+ const char *name;
uint8_t revision; /* revision number */
uint8_t family; /* supported family */
uint8_t dimension; /* elem dimension */
Index: ipset/lib/types.c
===================================================================
--- ipset.orig/lib/types.c
+++ ipset/lib/types.c
@@ -441,13 +441,15 @@ ipset_type_add(struct ipset_type *type)
assert(type);
+ if (strlen(type->name) > IPSET_MAXNAMELEN - 1)
+ return -EINVAL;
+
/* Add to the list: higher revision numbers first */
for (t = typelist, prev = NULL; t != NULL; t = t->next) {
if (STREQ(t->name, type->name)) {
- if (t->revision == type->revision) {
- errno = EEXIST;
- return -1;
- } else if (t->revision < type->revision) {
+ if (t->revision == type->revision)
+ return -EEXIST;
+ else if (t->revision < type->revision) {
type->next = t;
if (prev)
prev->next = type;
@@ -457,10 +459,9 @@ ipset_type_add(struct ipset_type *type)
}
}
if (t->next != NULL && STREQ(t->next->name, type->name)) {
- if (t->next->revision == type->revision) {
- errno = EEXIST;
- return -1;
- } else if (t->next->revision < type->revision) {
+ if (t->next->revision == type->revision)
+ return -EEXIST;
+ else if (t->next->revision < type->revision) {
type->next = t->next;
t->next = type;
return 0;
next prev parent reply other threads:[~2011-01-24 21:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-24 21:36 [patch 0/6] Ipset patches Holger Eitzenberger
2011-01-24 21:36 ` Holger Eitzenberger [this message]
2011-01-25 20:26 ` [patch 1/6] ipset: turn Set name[] into a const pointer Jozsef Kadlecsik
2011-01-24 21:36 ` [patch 2/6] ipset: fix the Netlink sequence number Holger Eitzenberger
2011-01-25 20:26 ` Jozsef Kadlecsik
2011-01-24 21:36 ` [patch 3/6] ipset: pass ipset_arg argument pointer Holger Eitzenberger
2011-01-25 20:42 ` Jozsef Kadlecsik
2011-01-27 10:06 ` Jozsef Kadlecsik
2011-02-01 20:10 ` Jozsef Kadlecsik
2011-01-24 21:36 ` [patch 4/6] ipset: avoid the unnecessary argv[] loop Holger Eitzenberger
2011-01-24 21:36 ` [patch 5/6] ipset: improve command argument parsing Holger Eitzenberger
2011-01-24 21:36 ` [patch 6/6] ipset: fix spelling error Holger Eitzenberger
2011-01-25 20:43 ` Jozsef Kadlecsik
2011-01-26 17:57 ` Ferenc Wagner
2011-01-26 22:53 ` Jozsef Kadlecsik
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=20110124214009.410600508@jonathan.eitzenberger.org \
--to=holger@eitzenberger.org \
--cc=kadlec@blackhole.kfki.hu \
--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 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).