Phil Oester <kernel@xxxxxxxxxxxx> wrote: > 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. Personally I think libraries should not change errno at all. > 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; > } I don't understand how this changes anything? #include <errno.h> #include <stdio.h> #include <stdlib.h> int main(void) { errno = EINVAL; void *v = malloc(0xffffffffffffffff); if (v == 0) perror("malloc"); } Yields "Cannot allocate memory", not "Invalid argument". -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html