Re: [PATCH] netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary

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

 



Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> wrote:
> On Wed, May 15, 2013 at 02:33:36PM +0200, Florian Westphal wrote:
> > > +	const struct xt_tcpoptstrip_target_info *info = par->targinfo;
> > >  	unsigned int optl, i, j;
> > >  	struct tcphdr *tcph;
> > >  	u_int16_t n, o;
> > >  	u_int8_t *opt;
> > > +	int len;
> > > +
> > [..]
> > > +	len = skb->len - tcphoff;
> > > +	if (len < sizeof(struct tcphdr))
> > 
> > I think this needs a cast 'if (len < (int) sizeof( ...?
> 
> I'm not hitting any compilation warning.

len is signed, thats why i asked, and, afair recall sizeof
is unsigned and thus len is treated as unsigned.

Test program yields:

#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
        char foo[20];
        int len = atoi(argc > 1 ? argv[1] : "0");
        if (len < sizeof(foo))
                printf("%d lt %lu\n", len, sizeof(foo));
        else
                printf("%d ge %lu\n", len, sizeof(foo));
        return 0;
}
t.c: In function 'main':
t.c:7:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
./t -42
-42 ge 20

gcc version 4.6.3.
--
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