src/usr.sbin/mountd/mountd.c
/*
 * Check that the sockaddr is a valid netmask. Returns 0 if the mask
 * is acceptable (i.e. of the form 1...10....0).
 */
Check that the sockaddr is a valid netmask. Returns 0 if the mask
is acceptable .
Check that the sockaddr is a valid netmask . Returns 0 if the mask is acceptable .
static int
checkmask(struct sockaddr *sa)
{
	u_char *mask;
	int i, len;
	if ((mask = sa_rawaddr(sa, &len)) == NULL)
		return (-1);
	for (i = 0; i < len; i++)
		if (mask[i] != 0xff)
			break;
	if (i < len) {
		if (~mask[i] & (u_char)(~mask[i] + 1))
			return (-1);
		i++;
	}
	for (; i < len; i++)
		if (mask[i] != 0)
			return (-1);
	return (0);
}
static int checkmask ( struct sockaddr * sa ) { u_char * mask ; int i , len ; if ( ( mask = sa_rawaddr ( sa , & len ) ) == NULL ) return ( -1 ) ; for ( i = 0 ; i < len ; i ++ ) if ( mask [ i ] != 0xff ) break ; if ( i < len ) { if ( ~ mask [ i ] & ( u_char ) ( ~ mask [ i ] + 1 ) ) return ( -1 ) ; i ++ ; } for ( ; i < len ; i ++ ) if ( mask [ i ] != 0 ) return ( -1 ) ; return ( 0 ) ; }
Check that the sockaddr is a valid netmask.
Check that the sockaddr is a valid netmask .