]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Disallow assigning [#]. Fixes #1171
authorAlan T. DeKok <aland@freeradius.org>
Wed, 19 Aug 2015 10:28:50 +0000 (06:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 19 Aug 2015 10:29:08 +0000 (06:29 -0400)
src/main/map.c
src/tests/map/count-error [new file with mode: 0644]
src/tests/map/count-list-error [new file with mode: 0644]

index e2f142f865b30fb63e21b254792af6b5abd6920a..88d89c19130e70b4c0ef6504947bbdf21556fc44 100644 (file)
@@ -285,6 +285,16 @@ int map_afrom_cp(TALLOC_CTX *ctx, vp_map_t **out, CONF_PAIR *cp,
                goto error;
        }
 
+       /*
+        *      We cannot assign a count to an attribute.  That must
+        *      be done in an xlat.
+        */
+       if ((map->rhs->type == TMPL_TYPE_ATTR) &&
+           (map->rhs->tmpl_num == NUM_COUNT)) {
+               cf_log_err_cp(cp, "Cannot assign from a count");
+               goto error;
+       }
+
        VERIFY_MAP(map);
 
        *out = map;
diff --git a/src/tests/map/count-error b/src/tests/map/count-error
new file mode 100644 (file)
index 0000000..925360d
--- /dev/null
@@ -0,0 +1,6 @@
+#
+#      This should be an xlat, not a direct assignment
+#
+update request {
+       Tmp-Integer-0 := &Filter-Id[#]  # ERROR
+}
\ No newline at end of file
diff --git a/src/tests/map/count-list-error b/src/tests/map/count-list-error
new file mode 100644 (file)
index 0000000..a7beae1
--- /dev/null
@@ -0,0 +1,6 @@
+#
+#      Updating lists isn't allowed
+#
+update {
+       &request:Filter-Id := &Filter-Id[#]     # ERROR
+}