Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Nov 2003 13:07:48 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Nate Lawson <nate@root.org>
Cc:        cvs-all@freebsd.org
Subject:   Re: cvs commit: src/sys/netinet ip_fastfwd.c
Message-ID:  <20031116125743.O3188@gamplex.bde.org>
In-Reply-To: <20031115121034.K54473@root.org>
References:  <20031115170411.6330416A4E9@hub.freebsd.org> <20031115121034.K54473@root.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 15 Nov 2003, Nate Lawson wrote:

> On Sat, 15 Nov 2003, Andre Oppermann wrote:
> > --- src/sys/netinet/ip_fastfwd.c:1.1	Fri Nov 14 13:02:21 2003
> > +++ src/sys/netinet/ip_fastfwd.c	Sat Nov 15 09:03:37 2003
> > @@ -567,7 +567,7 @@
> >  					goto drop;
> >  				}
> >  				tag->m_flags = PACKET_TAG_DIVERT;
> > -				tag->m_data = (caddr_t)(u_int32_t)args.divert_rule;
> > +				tag->m_data = (caddr_t)(u_long)args.divert_rule;
> >  				tag->m_next = m;
> >  				/* XXX: really bloody hack, see ip_input */
> >  				tag->m_nextpkt = (struct mbuf *)1;
>
> I believe this cast is still bogus.  You want uintptr_t.

Actually intptr_t.  The code that converts the value back to an int uses
intptr_t, and mixing uintptr_t with intptr_t gives an implementation-defined
total conversion which is not necessarily the identity.

After fixing this, the other half of the cast would be still be bogus.
intptr_t and uintptr_t only have defined behaviour for conversions to
and from void *, but caddr_t is supposed to be an opaque type.  caddr_t
happens to be char *, so it is equivalent to void * in most contexts
including probably this one, but but it takes much more familiarity with
C to know this than to know what [u]intptr_t does.  Using caddr_t is
bogus for other reasons; it should never be used, but it is still used
for the type of m_data, so the above code has to be aware of it.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031116125743.O3188>