netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary
Date: Wed, 15 May 2013 16:48:24 +0200	[thread overview]
Message-ID: <20130515144824.GG18095@breakpoint.cc> (raw)
In-Reply-To: <20130515135935.GA1605@localhost>

Pablo Neira Ayuso <pablo@netfilter.org> 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.

  reply	other threads:[~2013-05-15 14:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15 12:05 [PATCH] netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary Pablo Neira Ayuso
2013-05-15 12:33 ` Florian Westphal
2013-05-15 13:59   ` Pablo Neira Ayuso
2013-05-15 14:48     ` Florian Westphal [this message]
2013-05-15 15:10       ` Pablo Neira Ayuso

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=20130515144824.GG18095@breakpoint.cc \
    --to=fw@strlen.de \
    --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).