]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Fix string ordering
authorOndrej Zajicek <santiago@crfreenet.org>
Tue, 10 Feb 2026 02:41:59 +0000 (03:41 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 10 Feb 2026 02:41:59 +0000 (03:41 +0100)
Function strcmp() returns negative / 0 / positive, but val_compare()
is expected to return -1 / 0 / 1.

filter/data.c

index 9b052f894a5d5b95901e22eeac4ed5422c6e5b17..9bcab5048a87d6a1fd5953cc21d6bb5ab7d36cf8 100644 (file)
@@ -210,7 +210,8 @@ val_compare(const struct f_val *v1, const struct f_val *v2)
   case T_NET:
     return net_compare(v1->val.net, v2->val.net);
   case T_STRING:
-    return strcmp(v1->val.s, v2->val.s);
+    int i = strcmp(v1->val.s, v2->val.s);
+    return (i > 0) - (i < 0);
   case T_PATH:
     return as_path_compare(v1->val.ad, v2->val.ad);
   case T_ROUTE: