From 1a5f92d2faf924b1a5109ed370932ef66a35746a Mon Sep 17 00:00:00 2001 From: Nick Porter Date: Wed, 8 Jan 2025 09:16:21 +0000 Subject: [PATCH] Skip LDAP updates when tmpl produces zero length output --- src/modules/rlm_ldap/rlm_ldap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index ef5fb598d6..d3ae16a984 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -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; + } } /* -- 2.47.3