This is the mail archive of the
mailing list for the glibc project.
Re: CMSG_FIRSTHDR() and CMSG_NXTHDR()
- To: YOSHIFUJI Hideaki / $B5HF#1QL@(B
<yoshfuji at wide dot ad dot jp>
- Subject: Re: CMSG_FIRSTHDR() and CMSG_NXTHDR()
- From: James Antill <james at and dot org>
- Date: 12 May 2001 00:23:59 -0400
- Cc: libc-alpha at sources dot redhat dot com, usagi-core at linux-ipv6 dot org
- References: <20010512013616K.email@example.com>
YOSHIFUJI Hideaki / $B5HF#1QL@(B <firstname.lastname@example.org> writes:
> CMSG_NXTHDR() in glibc-2.2.x ignores last ancillary data.
> Here's the fix.
I sent in a patch for the second test below a while ago (Message-ID:
<email@example.com>) and thought about the first test (the
one you are supplying a patch for) but I couldn't think of how a
cmsghdr could only be the size of a cmsghdr?
The header itself only contains:
...surely you have to add something to that for it to be useful?
My guess would that that either something is going wrong somewhere
else and chopping the end of your data off, or you are running against
an older version of libc that doesn't have the second check converted
from a >= to > (the last line of context in your patch).
Either way I don't think there is a bug in glibc currently.
> USAGI CVS Branch: b2_2_3-FIX_20010512
> Index: sysdeps/unix/sysv/linux/cmsg_nxthdr.c
> RCS file: /cvsroot/usagi/usagi/libc/glibc22/sysdeps/unix/sysv/linux/cmsg_nxthdr.c,v
> retrieving revision 184.108.40.206
> retrieving revision 220.127.116.11.2.1
> diff -u -r18.104.22.168 -r22.214.171.124.2.1
> --- sysdeps/unix/sysv/linux/cmsg_nxthdr.c 2001/04/30 16:42:10 126.96.36.199
> +++ sysdeps/unix/sysv/linux/cmsg_nxthdr.c 2001/05/11 15:59:02 188.8.131.52.2.1
> @@ -29,7 +29,7 @@
> cmsg = (struct cmsghdr *) ((unsigned char *) cmsg
> + CMSG_ALIGN (cmsg->cmsg_len));
> - if ((unsigned char *) (cmsg + 1) >= ((unsigned char *) mhdr->msg_control
> + if ((unsigned char *) (cmsg + 1) > ((unsigned char *) mhdr->msg_control
> + mhdr->msg_controllen)
> || ((unsigned char *) cmsg + CMSG_ALIGN (cmsg->cmsg_len)
> > ((unsigned char *) mhdr->msg_control + mhdr->msg_controllen)))
[snip ... ]
# James Antill -- firstname.lastname@example.org
* ^From: .*james@and\.org