[Date Prev][Date Next] [Chronological] [Thread] [Top]

data loss, memory leak in attr_merge() (ITS#1481)



Full_Name: George Powers
Version: 2.0.18
OS: RedHat Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (207.78.98.2)



If the entry does not already have the target attribute, then attr_merge()
will allocate and abandon a new attribute without having attached it to the
entry.

int
attr_merge(
	Entry		*e,
	AttributeDescription *desc,
	struct berval	**vals )
{
	Attribute	**a;

	for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
		if ( ad_cmp( (*a)->a_desc, desc ) == 0 )
		{
			break;
		}
	}

	if ( *a == NULL ) {
		*a = (Attribute *) ch_malloc( sizeof(Attribute) );
		(*a)->a_desc = ad_dup( desc );
		(*a)->a_vals = NULL;
		(*a)->a_next = NULL;
	}

	return( value_add( &(*a)->a_vals, vals ) );
}