]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Skip LDAP updates when tmpl produces zero length output
authorNick Porter <nick@portercomputing.co.uk>
Wed, 8 Jan 2025 09:16:21 +0000 (09:16 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 8 Jan 2025 09:16:21 +0000 (09:16 +0000)
src/modules/rlm_ldap/rlm_ldap.c

index ef5fb598d605df92a7e8cf45bf3f2cfd22463037..d3ae16a98488b5ab4b4be483d72a9f0b9d61a1f7 100644 (file)
@@ -2031,12 +2031,14 @@ static unlang_action_t user_modify_mod_build_resume(rlm_rcode_t *p_result, UNUSE
                while ((vb = fr_value_box_list_pop_head(&usermod_ctx->expanded))) {
                        switch (vb->type) {
                        case FR_TYPE_OCTETS:
+                               if (vb->vb_length == 0) continue;
                                memcpy(&values[i].bv_val, &vb->vb_octets, sizeof(values[i].bv_val));
                                values[i].bv_len = vb->vb_length;
                                break;
 
                        case FR_TYPE_STRING:
                        populate_string:
+                               if (vb->vb_length == 0) continue;
                                memcpy(&values[i].bv_val, &vb->vb_strvalue, sizeof(values[i].bv_val));
                                values[i].bv_len = vb->vb_length;
                                break;
@@ -2067,6 +2069,10 @@ static unlang_action_t user_modify_mod_build_resume(rlm_rcode_t *p_result, UNUSE
                        value_refs[i] = &values[i];
                        i++;
                }
+               if (i == 0) {
+                       RDEBUG2("Expansion \"%s\" produced zero length value, skipping attribute \"%s\"", mod->tmpl->name, mod->attr);
+                       goto next;
+               }
        }
 
        /*