From: Alan T. DeKok Date: Wed, 24 May 2023 14:19:25 +0000 (-0400) Subject: minor cleanups X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1041fb1926bc78e287f17dd5de3ce16cbd029004;p=thirdparty%2Ffreeradius-server.git minor cleanups 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. --- diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index 21898f0eef6..235ea538128 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -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;