]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Fix bitfield attributes
authorOndrej Zajicek <santiago@crfreenet.org>
Thu, 28 Mar 2024 18:46:24 +0000 (19:46 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 28 Mar 2024 18:46:24 +0000 (19:46 +0100)
Fix missing route lookup, causing crash when accessing route attribute.

Also fix additional space in bitfield formatting.

nest/rt-attr.c
sysdep/linux/netlink.Y

index 468b279d114679e9bd21966fc86d926a28beb15a..1df1f96dc6dc97ea5c1073ecd744ca7a71b7e9eb 100644 (file)
@@ -1248,6 +1248,7 @@ ea_list_unref(ea_list *l)
 void
 ea_format_bitfield(const struct eattr *a, byte *buf, int bufsize, const char **names, int min, int max)
 {
+  byte *start = buf;
   byte *bound = buf + bufsize - 32;
   u32 data = a->u.data;
   int i;
@@ -1261,13 +1262,17 @@ ea_format_bitfield(const struct eattr *a, byte *buf, int bufsize, const char **n
        return;
       }
 
-      buf += bsprintf(buf, " %s", names[i]);
+      buf += bsprintf(buf, "%s ", names[i]);
       data &= ~(1u << i);
     }
 
   if (data)
-    bsprintf(buf, " %08x", data);
+    bsprintf(buf, "%08x ", data);
 
+  if (buf != start)
+    buf--;
+
+  *buf = 0;
   return;
 }
 
index 8e1c1921a3794c1160717b54dac173f5baef297e..bf5f8b3be656783e5f32f25733c5f1f008471e1b 100644 (file)
@@ -54,7 +54,7 @@ attr_bit: KRT_FEATURE_ECN     { $$ = f_new_dynamic_attr_bit(0, "krt_features"); } ;
 attr_bit: KRT_FEATURE_ALLFRAG { $$ = f_new_dynamic_attr_bit(3, "krt_features"); } ;
 
 /* Using attribute bits in filters (moved here to not confuse Bison on *BSD) */
-lvalue: attr_bit { $$ = (struct f_lval) { .type = F_LVAL_ATTR_BIT, .fab = $1 }; };
+lvalue: attr_bit { $$ = (struct f_lval) { .type = F_LVAL_ATTR_BIT, .fab = $1, .rte = f_new_inst(FI_CURRENT_ROUTE), }; };
 
 CF_CODE