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@xxxxxxxxxxxx>
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;