FreeBSD/sys/kern/imgact_binmisc.c
/*
 * Allocate memory and populate a new entry for the interpreter table.
 */
Allocate memory and populate a new entry for the interpreter table.
Allocate memory and populate a new entry for the interpreter table .
static imgact_binmisc_entry_t *
imgact_binmisc_new_entry(ximgact_binmisc_entry_t *xbe)
{
	imgact_binmisc_entry_t *ibe = NULL;
	size_t namesz = min(strlen(xbe->xbe_name) + 1, IBE_NAME_MAX);
	ibe = malloc(sizeof(*ibe), M_BINMISC, M_WAITOK|M_ZERO);
	ibe->ibe_name = malloc(namesz, M_BINMISC, M_WAITOK|M_ZERO);
	strlcpy(ibe->ibe_name, xbe->xbe_name, namesz);
	imgact_binmisc_populate_interp(xbe->xbe_interpreter, ibe);
	ibe->ibe_magic = malloc(xbe->xbe_msize, M_BINMISC, M_WAITOK|M_ZERO);
	memcpy(ibe->ibe_magic, xbe->xbe_magic, xbe->xbe_msize);
	ibe->ibe_mask = malloc(xbe->xbe_msize, M_BINMISC, M_WAITOK|M_ZERO);
	memcpy(ibe->ibe_mask, xbe->xbe_mask, xbe->xbe_msize);
	ibe->ibe_moffset = xbe->xbe_moffset;
	ibe->ibe_msize = xbe->xbe_msize;
	ibe->ibe_flags = xbe->xbe_flags;
	return (ibe);
}
static imgact_binmisc_entry_t * imgact_binmisc_new_entry ( ximgact_binmisc_entry_t * xbe ) { imgact_binmisc_entry_t * ibe = NULL ; size_t namesz = min ( strlen ( xbe -> xbe_name ) + 1 , IBE_NAME_MAX ) ; ibe = malloc ( sizeof ( * ibe ) , M_BINMISC , M_WAITOK | M_ZERO ) ; ibe -> ibe_name = malloc ( namesz , M_BINMISC , M_WAITOK | M_ZERO ) ; strlcpy ( ibe -> ibe_name , xbe -> xbe_name , namesz ) ; imgact_binmisc_populate_interp ( xbe -> xbe_interpreter , ibe ) ; ibe -> ibe_magic = malloc ( xbe -> xbe_msize , M_BINMISC , M_WAITOK | M_ZERO ) ; memcpy ( ibe -> ibe_magic , xbe -> xbe_magic , xbe -> xbe_msize ) ; ibe -> ibe_mask = malloc ( xbe -> xbe_msize , M_BINMISC , M_WAITOK | M_ZERO ) ; memcpy ( ibe -> ibe_mask , xbe -> xbe_mask , xbe -> xbe_msize ) ; ibe -> ibe_moffset = xbe -> xbe_moffset ; ibe -> ibe_msize = xbe -> xbe_msize ; ibe -> ibe_flags = xbe -> xbe_flags ; return ( ibe ) ; }
Allocate memory and populate a new entry for the interpreter table.
Allocate memory and populate a new entry for the interpreter table .