* but for the readability the full list is supported.
*/
struct ipset_type {
- char name[IPSET_MAXNAMELEN]; /* type name */
+ const char *name;
uint8_t revision; /* revision number */
uint8_t family; /* supported family */
uint8_t dimension; /* elem dimension */
assert(type);
+ if (strlen(type->name) > IPSET_MAXNAMELEN - 1)
+ return -EINVAL;
+
/* Add to the list: higher revision numbers first */
for (t = typelist, prev = NULL; t != NULL; t = t->next) {
if (STREQ(t->name, type->name)) {
- if (t->revision == type->revision) {
- errno = EEXIST;
- return -1;
- } else if (t->revision < type->revision) {
+ if (t->revision == type->revision)
+ return -EEXIST;
+ else if (t->revision < type->revision) {
type->next = t;
if (prev)
prev->next = type;
}
}
if (t->next != NULL && STREQ(t->next->name, type->name)) {
- if (t->next->revision == type->revision) {
- errno = EEXIST;
- return -1;
- } else if (t->next->revision < type->revision) {
+ if (t->next->revision == type->revision)
+ return -EEXIST;
+ else if (t->next->revision < type->revision) {
type->next = t->next;
t->next = type;
return 0;