]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Pop box from list before manipulation
authorNick Porter <nick@portercomputing.co.uk>
Fri, 10 Jan 2025 09:33:03 +0000 (09:33 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 10 Jan 2025 09:33:03 +0000 (09:33 +0000)
fr_value_box_strdup re-initialises the box, which clears the list
pointers, meaning list_remove won't work.

src/lib/curl/xlat.c

index 2e5866c1ca2b983eb20ba3b41795da078a1e9679..84a4fcc4aa88fbc95e55d37a67e6545916338e31 100644 (file)
@@ -46,7 +46,7 @@ xlat_action_t fr_curl_xlat_uri_escape(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out,
                                      UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request,
                                      fr_value_box_list_t *in)
 {
-       fr_value_box_t  *to_escape = fr_value_box_list_head(in);
+       fr_value_box_t  *to_escape = fr_value_box_list_pop_head(in);
        char            *escaped;
 
        escaped = curl_easy_escape(fr_curl_tmp_handle(), to_escape->vb_strvalue, to_escape->vb_length);
@@ -62,8 +62,6 @@ xlat_action_t fr_curl_xlat_uri_escape(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out,
 
 done:
        curl_free(escaped);
-
-       fr_value_box_list_remove(in, to_escape);
        fr_dcursor_insert(out, to_escape);
 
        return XLAT_ACTION_DONE;
@@ -76,12 +74,10 @@ xlat_action_t fr_curl_xlat_uri_unescape(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *ou
                                        UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request,
                                        fr_value_box_list_t *in)
 {
-       fr_value_box_t  *to_unescape = fr_value_box_list_head(in);
+       fr_value_box_t  *to_unescape = fr_value_box_list_pop_head(in);
        int             unescaped_len;
        char            *unescaped;
 
-       fr_value_box_list_remove(in, to_unescape);
-
        unescaped = curl_easy_unescape(fr_curl_tmp_handle(), to_unescape->vb_strvalue, to_unescape->vb_length, &unescaped_len);
        if (!unescaped) {
                talloc_free(to_unescape);