Re: [PATCH] iptables: set errno correctly in iptcc_chain_index_alloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phil Oester <kernel@xxxxxxxxxxxx> wrote:
> Simulate an out of memory condition with this patch
> 
> @@ -500,9 +500,11 @@ static int iptcc_chain_index_alloc(struct xtc_handle *h)
>               array_elems, array_mem);
> 
>         h->chain_index = malloc(array_mem);
> -       if (h->chain_index == NULL && array_mem > 0) {
> +       //if (h->chain_index == NULL && array_mem > 0) {
> +       if (1) {
>                 h->chain_index_sz = 0;
> With the patch, the error message returned to user:
> 
>    ...can't initialize iptables table `filter': Memory allocation problem
> 
> without the patch:
> 
>    ...can't initialize iptables table `filter': Incompatible with this kernel
> 
> The former seems better, no?

Yes, but malloc didn't fail, so malloc didn't set errno.

My point is, that we should not muck with errno, especially
after libc functions that usually already set it on error.
--
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




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux