From: Phil Oester <kernel@linuxace.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [PATCH] iptables: set errno correctly in iptcc_chain_index_alloc
Date: Wed, 3 Jul 2013 18:16:10 -0700 [thread overview]
Message-ID: <20130704011610.GA9791@linuxace.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 439 bytes --]
As reported by Robert Barnhardt, iptcc_chain_index_alloc does not populate
errno with the appropriate ENOMEM on allocation failures. This causes
incorrect error messages to be passed back to user such as "can't initialize
iptables table 'X'" even if the issue was caused by OOM condition. Fix
this by passing back ENOMEM if allocation failure occurs.
This closes bugzilla #619.
Phil
Signed-off-by: Phil Oester <kernel@linuxace.com>
[-- Attachment #2: patch-enomem --]
[-- Type: text/plain, Size: 450 bytes --]
diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
index f0f7815..004b0ec 100644
--- a/libiptc/libiptc.c
+++ b/libiptc/libiptc.c
@@ -502,7 +502,8 @@ static int iptcc_chain_index_alloc(struct xtc_handle *h)
h->chain_index = malloc(array_mem);
if (h->chain_index == NULL && array_mem > 0) {
h->chain_index_sz = 0;
- return -ENOMEM;
+ errno = ENOMEM;
+ return -1;
}
memset(h->chain_index, 0, array_mem);
h->chain_index_sz = array_elems;
next reply other threads:[~2013-07-04 1:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 1:16 Phil Oester [this message]
2013-07-04 7:42 ` [PATCH] iptables: set errno correctly in iptcc_chain_index_alloc Florian Westphal
2013-07-04 16:18 ` Phil Oester
2013-07-04 16:33 ` Florian Westphal
2013-07-04 16:52 ` Phil Oester
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=20130704011610.GA9791@linuxace.com \
--to=kernel@linuxace.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).