cvs commit: src/sys/netinet ip_fastfwd.c
Bruce Evans
bde at zeta.org.au
Sat Nov 15 18:07:56 PST 2003
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
More information about the cvs-src
mailing list