Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 318801 - sys-apps/man-pages-3.23 cmsg(3) inconsistency
Summary: sys-apps/man-pages-3.23 cmsg(3) inconsistency
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Linux bug wranglers
URL: https://bugzilla.kernel.org/show_bug....
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-06 21:20 UTC by Christopher Head
Modified: 2010-05-09 22:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Head 2010-05-06 21:20:52 UTC
In man page cmsg(3), I see the following prose:

"Finally, the msg_controllen field of the msghdr should be set to the sum of the CMSG_SPACE() of the length of all control messages in the buffer. For more  information on the msghdr, see recvmsg(2)."

Then, in the sample code at the bottom, I see this code:
           msg.msg_control = buf;
           msg.msg_controllen = sizeof buf;
           cmsg = CMSG_FIRSTHDR(&msg);
           cmsg->cmsg_level = SOL_SOCKET;
           cmsg->cmsg_type = SCM_RIGHTS;
           cmsg->cmsg_len = CMSG_LEN(sizeof(int) * NUM_FD);
           /* Initialize the payload: */
           fdptr = (int *) CMSG_DATA(cmsg);
           memcpy(fdptr, myfds, NUM_FD * sizeof(int));
           /* Sum of the length of all control messages in the buffer: */
           msg.msg_controllen = cmsg->cmsg_len;

This is inconsistent: the prose states that msg_controllen should be initialized with the sum of CMSG_SPACE across all messages, whereas the example code shows msg_controllen being initialized with cmsg->cmsg_len, which is itself initialized with CMSG_LEN, not CMSG_SPACE.

I don't know what the right answer is, but for control messages whose length is not a multiple of the alignment requirement, this could make a difference.

Reproducible: Always

Steps to Reproduce:
Comment 2 Christopher Head 2010-05-07 08:18:42 UTC
No, this hasn't gone upstream. I didn't know where exactly upstream was for the man-pages package. Do you want me to report it, or will you?
Comment 3 Michael Weber (RETIRED) gentoo-dev 2010-05-07 11:21:19 UTC
Since i don't know the exact problem with the ebuilds, it would be better if you file the upstream bug and attach it's link to this bug (URL field).

But i can provide you with informations about how to get informations about packages.

-(if you have eix installed) `eix <package>` lists the homepage which should reveal a upstream bugtracker. Ok, this example is ab bit tricky the find the right package and not fall into the kernel attractor.

You can also look at the SRC_URI entries of the ebuild ( vi `equery which <package>` ) or search for it in the mention /var/tmp/portage/<category>/<package full version>/temp/environment file. In this case you see the gentoo specific patch set beside the upstream sources.

[Test if it's resolved in newer version]
You can run "ebuild `ACCEPT_KEYWORDS=~* equery which man-pages` clean unpack" and investigate the situation in the latest in the .../work directory. You can replace unpack with install (this does not install to system /) and look at the .../image directory what this version would install. 

It's not that complicated to examine where the bits come from. "man 1 ebuild" and man 5 ebuild" is a good starting point, if you're willing to know how Gentoo is installing things. I don't know if there's a regular user compartible guide for things like that. http://devmanual.gentoo.org needs some time to get things together.