/*
* Free the dictionary_attributes and dictionary_values lists.
*/
-static void dict_free(void)
+void dict_free(void)
{
DICT_VENDOR *dvend, *enext;
}
}
+ if (value >= 65536) {
+ librad_log("dict_addattr: ATTRIBUTE has invalid number.");
+ return -1;
+ }
/*
* Create a new attribute for the list
* Add the value into the dictionary.
*/
if (rbtree_insert(values_byname, dval) == 0) {
+ if (dattr) {
+ DICT_VALUE *dup;
+
+ /*
+ * Suppress duplicates with the same
+ * name and value. There are lots in
+ * dictionary.ascend.
+ */
+ dup = dict_valbyname(dattr->attr, namestr);
+ if (dup && (dup->value == dval->value)) {
+ free(dval);
+ return 0;
+ }
+ }
+
librad_log("dict_addvalue: Duplicate value name %s for attribute %s", namestr, attrstr);
return -1;
}
((const DICT_VALUE *)b)->attr);
if (rcode != 0) return rcode;
- return strcasecmp(((const DICT_VALUE *)a)->name,
+return strcasecmp(((const DICT_VALUE *)a)->name,
((const DICT_VALUE *)b)->name);
}
return -1;
}
- values_byname = rbtree_create(valuename_cmp, NULL, 1);
+ values_byname = rbtree_create(valuename_cmp, free, 0);
if (!values_byname) {
return -1;
}