FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Check rule head in FreeBSD8 format
 *
 */
Check rule head in FreeBSD8 format
Check rule head in FreeBSD8 format
static int
check_ipfw_rule0(struct ip_fw_rule0 *rule, int size,
    struct rule_check_info *ci)
{
	int l;
	if (size < sizeof(*rule)) {
		printf("ipfw: rule too short\n");
		return (EINVAL);
	}
	l = sizeof(*rule) + rule->cmd_len * 4 - 4;
	if (l != size) {
		printf("ipfw: size mismatch (have %d want %d)\n", size, l);
		return (EINVAL);
	}
	if (rule->act_ofs >= rule->cmd_len) {
		printf("ipfw: bogus action offset (%u > %u)\n",
		    rule->act_ofs, rule->cmd_len - 1);
		return (EINVAL);
	}
	if (rule->rulenum > IPFW_DEFAULT_RULE - 1)
		return (EINVAL);
	return (check_ipfw_rule_body(rule->cmd, rule->cmd_len, ci));
}
static int check_ipfw_rule0 ( struct ip_fw_rule0 * rule , int size , struct rule_check_info * ci ) { int l ; if ( size < sizeof ( * rule ) ) { printf ( " \n " ) ; return ( EINVAL ) ; } l = sizeof ( * rule ) + rule -> cmd_len * 4 - 4 ; if ( l != size ) { printf ( " \n " , size , l ) ; return ( EINVAL ) ; } if ( rule -> act_ofs >= rule -> cmd_len ) { printf ( " \n " , rule -> act_ofs , rule -> cmd_len - 1 ) ; return ( EINVAL ) ; } if ( rule -> rulenum > IPFW_DEFAULT_RULE - 1 ) return ( EINVAL ) ; return ( check_ipfw_rule_body ( rule -> cmd , rule -> cmd_len , ci ) ) ; }
Check rule head in FreeBSD8 format
Check rule head in FreeBSD8 format
/* Check for valid cmd_len */