]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
minor cleanups
authorAlan T. DeKok <aland@freeradius.org>
Wed, 24 May 2023 14:19:25 +0000 (10:19 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 29 May 2023 14:43:04 +0000 (10:43 -0400)
the key is now expanded to a local value-box, instead of pointing
to an attribute which might be edited by the operations we're
doing.  As a result, we don't need to copy the key to a local
buffer.

src/modules/rlm_files/rlm_files.c

index 21898f0eef62d624a0d979938952136cdb8d84db..235ea5381280e3d3676adcbcca0ce06998bad367 100644 (file)
@@ -402,7 +402,10 @@ static unlang_action_t file_common(rlm_rcode_t *p_result, UNUSED rlm_files_t con
                trie = (tree->type == FR_HTRIE_TRIE);
 
                /*
-                *      Grab our own copy of the key if necessary.
+                *      Convert the value-box to a key for use in a trie.  The trie assumes that the key
+                *      starts at the high bit of the data, and that isn't always the case.  e.g. "bool" and
+                *      "integer" may be in host byte order, in which case we have to convert them to network
+                *      byte order.
                 */
                if (user_list && trie) {
                        key = key_buffer;
@@ -412,21 +415,6 @@ static unlang_action_t file_common(rlm_rcode_t *p_result, UNUSED rlm_files_t con
 
                        RDEBUG3("Keylen %ld", keylen);
                        RHEXDUMP3(key, (keylen + 7) >> 3, "KEY ");
-
-                       /*
-                        *      We're going to free the value_box
-                        *      shortly, so copy the key to our
-                        *      internal key buffer.
-                        */
-                       if (key != key_buffer) {
-                               if (((keylen + 7) >> 3) > sizeof(key_buffer)) {
-                                       REDEBUG("Key is too long - truncating");
-                                       keylen = sizeof(key_buffer) << 3;
-                               }
-
-                               memcpy(key_buffer, key, (keylen + 7) >> 3);
-                               key = key_buffer;
-                       }
                }
 
                user_pl = user_list ? fr_dlist_head(&user_list->head) : NULL;