]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more corner cases, as caught by ASAN
authorAlan T. DeKok <aland@freeradius.org>
Thu, 17 Nov 2022 14:34:37 +0000 (09:34 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 17 Nov 2022 14:34:37 +0000 (09:34 -0500)
src/lib/unlang/compile.c

index d77bb92413818c32b5d16ece06125a9c0cdc9958..e83dca5acf301fa0827d72f00f366922ee4b6d1c 100644 (file)
@@ -1434,7 +1434,11 @@ static unlang_t *compile_update_to_edit(unlang_t *parent, unlang_compile_t *unla
                         *      @todo - add support for &config?
                         */
                        if (fr_table_value_by_substr(pair_list_table, p, q - p, PAIR_LIST_UNKNOWN) != PAIR_LIST_UNKNOWN) {
-                               p = q + 1;
+                               if (*q) {
+                                       p = q + 1;
+                               } else {
+                                       p = NULL;
+                               }
                        }
 
                        /*
@@ -1449,14 +1453,20 @@ static unlang_t *compile_update_to_edit(unlang_t *parent, unlang_compile_t *unla
                                if (*p) {
                                        snprintf(lhs, sizeof(lhs), "&%s", p);
                                        attr = lhs;
+
                                } else {
                                        attr = NULL;
                                }
-                       } else {
+
+                       } else if (p) {
                                /*
                                 *      There is no list reference, so print out the default one.
                                 */
                                snprintf(list, sizeof(list), "&%s", fr_table_str_by_value(pair_list_table, unlang_ctx->rules->attr.list_def, "???"));
+
+                       } else {
+                               strlcpy(list, attr, sizeof(list));
+                               attr = NULL;
                        }
                }