]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more checks for is_root / vendor as per previous commit
authorAlan T. DeKok <aland@freeradius.org>
Wed, 21 Dec 2016 21:56:05 +0000 (16:56 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 21 Dec 2016 21:56:05 +0000 (16:56 -0500)
src/lib/pair.c
src/lib/pair_cursor.c

index 1fe397c3ddf2831b12ebbbe16499fcaba5e56a04..e9f9b4a4d7553a755c9dc2913214adab2a24e1df 100644 (file)
@@ -890,15 +890,31 @@ void fr_pair_delete_by_num(VALUE_PAIR **head, unsigned int vendor, unsigned int
        VALUE_PAIR *i, *next;
        VALUE_PAIR **last = head;
 
-       for(i = *head; i; i = next) {
-               VERIFY_VP(i);
-               next = i->next;
-               if ((i->da->attr == attr) && (i->da->vendor == vendor) &&
-                   (!i->da->flags.has_tag || TAG_EQ(tag, i->tag))) {
-                       *last = next;
-                       talloc_free(i);
-               } else {
-                       last = &i->next;
+       if (!vendor) {
+               for(i = *head; i; i = next) {
+                       VERIFY_VP(i);
+                       next = i->next;
+                       if (i->da->parent->flags.is_root &&
+                           (i->da->attr == attr) && (i->da->vendor == 0) &&
+                           (!i->da->flags.has_tag || TAG_EQ(tag, i->tag))) {
+                               *last = next;
+                               talloc_free(i);
+                       } else {
+                               last = &i->next;
+                       }
+               }
+       } else {
+               for(i = *head; i; i = next) {
+                       VERIFY_VP(i);
+                       next = i->next;
+                       if ((i->da->parent->type == PW_TYPE_VENDOR) &&
+                           (i->da->attr == attr) && (i->da->vendor == vendor) &&
+                           (!i->da->flags.has_tag || TAG_EQ(tag, i->tag))) {
+                               *last = next;
+                               talloc_free(i);
+                       } else {
+                               last = &i->next;
+                       }
                }
        }
 }
@@ -1648,8 +1664,16 @@ VALUE_PAIR *fr_pair_list_copy_by_num(TALLOC_CTX *ctx, VALUE_PAIR *from,
                        continue;
                }
 
-               if ((vp->da->attr != attr) || (vp->da->vendor != vendor)) {
-                       continue;
+               if (!vendor) {
+                       if (!vp->da->parent->flags.is_root ||
+                           (vp->da->attr != attr) || (vp->da->vendor != 0)) {
+                               continue;
+                       }
+               } else {
+                       if ((vp->da->parent->type != PW_TYPE_VENDOR) ||
+                           (vp->da->attr != attr) || (vp->da->vendor != vendor)) {
+                               continue;
+                       }
                }
 
        do_copy:
@@ -1712,7 +1736,7 @@ void fr_pair_list_move(TALLOC_CTX *ctx, VALUE_PAIR **to, VALUE_PAIR **from)
                /*
                 *      We never move Fall-Through.
                 */
-               if (!i->da->vendor && i->da->attr == PW_FALL_THROUGH) {
+               if (!i->da->vendor && i->da->attr == PW_FALL_THROUGH && i->da->parent->flags.is_root) {
                        tail_from = &(i->next);
                        continue;
                }
@@ -1910,9 +1934,18 @@ static void fr_pair_list_move_by_num_internal(TALLOC_CTX *ctx, VALUE_PAIR **to,
                /*
                 *      If it isn't an exact match, ignore it.
                 */
-               if (!((i->da->vendor == vendor) && (i->da->attr == attr))) {
-                       iprev = i;
-                       continue;
+               if (!vendor) {
+                       if (!(i->da->parent->flags.is_root &&
+                             (i->da->attr == attr) && (i->da->vendor == 0))) {
+                               iprev = i;
+                               continue;
+                       }
+               } else {
+                       if (!((i->da->parent->type == PW_TYPE_VENDOR) &&
+                             (i->da->attr == attr) && (i->da->vendor == vendor))) {
+                               iprev = i;
+                               continue;
+                       }
                }
 
        move:
index 0e8ac292c44254b888b965ca045b74a2587829b2..cfc7f2704c82a8d7e931616dc8b5b5a402ecce56 100644 (file)
@@ -221,7 +221,7 @@ VALUE_PAIR *fr_pair_cursor_next_by_num(vp_cursor_t *cursor, unsigned int vendor,
                     i != NULL;
                     i = i->next) {
                        VERIFY_VP(i);
-                       if (i->da->parent->type == PW_TYPE_VENDOR &&
+                       if ((i->da->parent->type == PW_TYPE_VENDOR) &&
                            (i->da->attr == attr) && (i->da->vendor == vendor) &&
                            (!i->da->flags.has_tag || TAG_EQ(tag, i->tag))) {
                                break;