Bug 172277

Summary: [openbsm] OpenBSM-21/openbsm/libbsm/bsm_token.c au_to_socket_ex comments contradicted by code
Product: Base System Reporter: Daniel U. Thibault <daniel.thibault>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me    
Priority: Normal    
Version: 1.0-CURRENT   
Hardware: Any   
OS: Any   

Description Daniel U. Thibault 2012-10-02 17:30:25 UTC
The au_to_socket_ex function of bsm_token.c (a component of the current libbsm implementation) reads in part:

/*
[...]
 * Domain and type arguments to this routine are assumed to already have been
 * converted to the BSM constant space, so we don't do that here.
 */
token_t *
au_to_socket_ex(u_short so_domain, u_short so_type,
    struct sockaddr *sa_local, struct sockaddr *sa_remote)
{
[...]
	ADD_U_INT16(dptr, au_domain_to_bsm(so_domain));
	ADD_U_INT16(dptr, au_socket_type_to_bsm(so_type));

The documentation claims the socket domain and type are assumed already converted to the BSM constant space, but the code invokes au_domain_to_bsm and au_socket_type_to_bsm, two functions (bsm_domain.c) which, unless I'm very much mistaken, actually do convert from the local domain to the BSM domain.

Either the documentation needs to be corrected, or the code is wrong.

Fix: 

If the documentation is to be fixed, change the au_to_socket_ex preamble to conclude with:

 * Domain and type arguments to this routine are assumed to be in the local
 * constant space; they are converted to the BSM constant space before
 * incorporation in the token.
 */
How-To-Repeat: Look up http://www.opensource.apple.com/source/OpenBSM/OpenBSM-21/openbsm/libbsm/bsm_token.c and http://www.opensource.apple.com/source/OpenBSM/OpenBSM-21/openbsm/libbsm/bsm_domain.c and search for au_to_socket_ex, au_domain_to_bsm and au_socket_type_to_bsm.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:45 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped