FreeBSD/contrib/openbsm/libbsm/bsm_audit.c
/*
 * Store the token with the record descriptor.
 *
 * Don't permit writing more to the buffer than would let the trailer be
 * appended later.
 */
Store the token with the record descriptor.
Don't permit writing more to the buffer than would let the trailer be
appended later.
Store the token with the record descriptor . Don ' t permit writing more to the buffer than would let the trailer be appended later .
int
au_write(int d, token_t *tok)
{
	au_record_t *rec;
	if (tok == NULL) {
		errno = EINVAL;
		return (-1); 
	}
	rec = open_desc_table[d];
	if ((rec == NULL) || (rec->used == 0)) {
		errno = EINVAL;
		return (-1); 
	}
	if (rec->len + tok->len + AUDIT_TRAILER_SIZE > MAX_AUDIT_RECORD_SIZE) {
		errno = ENOMEM;
		return (-1);
	}
	TAILQ_INSERT_TAIL(&rec->token_q, tok, tokens);
	rec->len += tok->len; 
	tok = NULL;
	return (0); 
}
int au_write ( int d , token_t * tok ) { au_record_t * rec ; if ( tok == NULL ) { errno = EINVAL ; return ( -1 ) ; } rec = open_desc_table [ d ] ; if ( ( rec == NULL ) || ( rec -> used == 0 ) ) { errno = EINVAL ; return ( -1 ) ; } if ( rec -> len + tok -> len + AUDIT_TRAILER_SIZE > MAX_AUDIT_RECORD_SIZE ) { errno = ENOMEM ; return ( -1 ) ; } TAILQ_INSERT_TAIL ( & rec -> token_q , tok , tokens ) ; rec -> len += tok -> len ; tok = NULL ; return ( 0 ) ; }
Store the token with the record descriptor.
Store the token with the record descriptor .
/* Invalid Token */ /* Write the token to the record descriptor */ /* Invalid descriptor */ /* Add the token to the tail */ /*
	 * XXX Not locking here -- we should not be writing to
	 * XXX the same descriptor from different threads
	 */ /* grow record length by token size bytes */ /* Token should not be available after this call */ /* Success */