]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use value-box API rather than hand-rolled code
authorAlan T. DeKok <aland@freeradius.org>
Sun, 1 Mar 2026 14:42:26 +0000 (09:42 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 1 Mar 2026 15:13:17 +0000 (10:13 -0500)
src/modules/rlm_ftp/rlm_ftp.c

index d84a2925c6c95ff50a11a5fbb543a6c00367cd90..a273fd5791a61e4ae6ad3f0774432dc262d17d3c 100644 (file)
@@ -124,22 +124,21 @@ global_lib_autoinst_t const * const rlm_ftp_lib[] = {
  */
 static int ftp_uri_part_escape(fr_value_box_t *vb, UNUSED void *uctx)
 {
-       char    *escaped, *str;
+       char    *escaped;
+       size_t  len;
 
        escaped = curl_easy_escape(fr_curl_tmp_handle(), vb->vb_strvalue, vb->vb_length);
        if (!escaped) return -1;
 
+       len = strlen(escaped);
+
        /*
         *      Returned string the same length - nothing changed
         */
-       if (strlen(escaped) == vb->vb_length) {
-               curl_free(escaped);
-               return 0;
+       if (len != vb->vb_length) {
+               MEM(fr_value_box_bstrndup(vb, vb, NULL, escaped, len, false) >= 0);
        }
 
-       str = talloc_strdup(vb, escaped);
-       fr_value_box_strdup_shallow_replace(vb, str, strlen(str));
-
        curl_free(escaped);
 
        return 0;