]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
make rad_filename_box_make_safe() idempotent
authorAlan T. DeKok <aland@freeradius.org>
Thu, 11 Jun 2026 11:46:20 +0000 (14:46 +0300)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 14 Jun 2026 12:56:50 +0000 (08:56 -0400)
src/lib/server/util.c
src/modules/rlm_smtp/rlm_smtp.c

index cbf993c0768de18dfcebacd279738fcfe7f8fe4f..32c720404e74d8c5f1beb14bd6ffaf0ca6c85120 100644 (file)
@@ -135,7 +135,7 @@ int rad_filename_box_make_safe(fr_value_box_t *vb, UNUSED void *uxtc)
 
        if (vb->vb_length == 0) return 0;
 
-       fr_assert(!fr_value_box_is_safe_for(vb, rad_filename_box_make_safe));
+       if (fr_value_box_is_safe_for(vb, rad_filename_box_make_safe)) return 1;
 
        /*
         *      Allocate an output buffer, only ever the same or shorter than the input
index 88cfb805df210d9365880df5e77b22b479b6427c..aa285b25f4d650c2d7eb78029a8da1b2039cb2cb 100644 (file)
@@ -295,11 +295,9 @@ static int str_to_attachments(fr_mail_ctx_t *uctx, curl_mime *mime, fr_value_box
                return -1;
        }
 
-       if (!fr_value_box_is_safe_for(vb, (fr_value_box_safe_for_t) rad_filename_box_make_safe)) {
-               if (rad_filename_box_make_safe(vb, NULL) < 0) {
-                       RPEDEBUG2("Failed escaping path");
-                       return -1;
-               }
+       if (rad_filename_box_make_safe(vb, NULL) < 0) {
+               RPEDEBUG2("Failed escaping path");
+               return -1;
        }
 
        if (fr_sbuff_in_bstrncpy(path_buffer, vb->vb_strvalue, vb->vb_length) < 0) {