From: Arran Cudbard-Bell Date: Mon, 21 May 2018 09:06:49 +0000 (+0600) Subject: Fixup any log messages which print vp_strvalue directly X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e18013caacf362d9cc7b66d24f6bc4bfa777e07a;p=thirdparty%2Ffreeradius-server.git Fixup any log messages which print vp_strvalue directly Should use %pV which is binary safe --- diff --git a/src/main/unit_test_module.c b/src/main/unit_test_module.c index a5837203db3..7e865917e04 100644 --- a/src/main/unit_test_module.c +++ b/src/main/unit_test_module.c @@ -1073,7 +1073,7 @@ int main(int argc, char *argv[]) unlang = cf_section_find(request->server_cs, "authenticate", auth_type); talloc_free(auth_type); if (!unlang) { - REDEBUG("Failed to find 'recv %s' section", auth_type); + REDEBUG("Failed to find 'recv %pV' section", &vp->data); request->reply->code = FR_CODE_ACCESS_REJECT; goto done; } diff --git a/src/main/xlat_func.c b/src/main/xlat_func.c index c8c7ec55f86..a82b24f959f 100644 --- a/src/main/xlat_func.c +++ b/src/main/xlat_func.c @@ -342,24 +342,21 @@ static ssize_t xlat_debug_attr(UNUSED TALLOC_CTX *ctx, UNUSED char **out, UNUSED vp = fr_cursor_next(&cursor)) { fr_dict_vendor_t const *vendor; FR_NAME_NUMBER const *type; - char *value; - value = fr_pair_value_asprint(vp, vp, '\''); if (vp->da->flags.has_tag) { - RIDEBUG2("&%s:%s:%i %s %s", + RIDEBUG2("&%s:%s:%i %s %pV", fr_int2str(pair_lists, vpt->tmpl_list, ""), vp->da->name, vp->tag, fr_int2str(fr_tokens_table, vp->op, ""), - value); + &vp->data); } else { - RIDEBUG2("&%s:%s %s %s", + RIDEBUG2("&%s:%s %s %pV", fr_int2str(pair_lists, vpt->tmpl_list, ""), vp->da->name, fr_int2str(fr_tokens_table, vp->op, ""), - value); + &vp->data); } - talloc_free(value); if (!RDEBUG_ENABLED3) continue; @@ -399,21 +396,16 @@ static ssize_t xlat_debug_attr(UNUSED TALLOC_CTX *ctx, UNUSED char **out, UNUSED break; } - dst = talloc_zero(vp, fr_value_box_t); + dst = fr_value_box_alloc_null(vp); /* We expect some to fail */ if (fr_value_box_cast(dst, dst, type->number, NULL, &vp->data) < 0) { goto next_type; } - value = fr_value_box_asprint(dst, dst, '\''); - if (!value) goto next_type; - - if ((pad = (11 - strlen(type->name))) < 0) { - pad = 0; - } + if ((pad = (11 - strlen(type->name))) < 0) pad = 0; RINDENT(); - RDEBUG2("as %s%*s: %s", type->name, pad, " ", value); + RDEBUG2("as %s%*s: %pV", type->name, pad, " ", dst); REXDENT(); next_type: diff --git a/src/modules/rlm_chap/rlm_chap.c b/src/modules/rlm_chap/rlm_chap.c index 009f6bd1354..d84e64bfe51 100644 --- a/src/modules/rlm_chap/rlm_chap.c +++ b/src/modules/rlm_chap/rlm_chap.c @@ -188,7 +188,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(UNUSED void *instance, UNUS return RLM_MODULE_REJECT; } - RDEBUG("CHAP user \"%s\" authenticated successfully", request->username->vp_strvalue); + RDEBUG("CHAP user \"%pV\" authenticated successfully", &request->username->data); return RLM_MODULE_OK; } diff --git a/src/modules/rlm_digest/rlm_digest.c b/src/modules/rlm_digest/rlm_digest.c index bf005589a50..57b517bcc1d 100644 --- a/src/modules/rlm_digest/rlm_digest.c +++ b/src/modules/rlm_digest/rlm_digest.c @@ -421,7 +421,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(UNUSED void *instance, UNUS * We check for "MD5-sess" and "MD5". * Anything else is an error. */ - REDEBUG("Unknown Digest-Algorithm \"%s\": Cannot perform Digest authentication", vp->vp_strvalue); + REDEBUG("%pP - Unknown Digest-Algorithm: Cannot perform Digest authentication", vp); return RLM_MODULE_INVALID; } @@ -479,7 +479,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(UNUSED void *instance, UNUS a2_len += body->vp_length; } else if (strcasecmp(qop->vp_strvalue, "auth") != 0) { - REDEBUG("Unknown Digest-QOP \"%s\": Cannot perform Digest authentication", qop->vp_strvalue); + REDEBUG("%pP - Unknown value: Cannot perform Digest authentication", qop); return RLM_MODULE_INVALID; } } diff --git a/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c b/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c index 33685f40b05..a3dbf9aac5a 100644 --- a/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c +++ b/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c @@ -677,7 +677,7 @@ static FR_CODE eap_fast_eap_payload(REQUEST *request, eap_session_t *eap_session int ret; eap_tunnel_data_t *tunnel; - RDEBUG("Tunneled authentication will be proxied to %s", vp->vp_strvalue); + RDEBUG("Tunneled authentication will be proxied to %pV", &vp->data); /* * Tell the original request that it's going to be proxied. diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c index 244e104b9bb..f8f36cda456 100644 --- a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c +++ b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c @@ -694,7 +694,7 @@ rlm_rcode_t eap_peap_process(eap_session_t *eap_session, tls_session_t *tls_sess fr_pair_value_bstrncpy(t->username, data + 1, data_len - 1); - RDEBUG("Got inner identity '%s'", t->username->vp_strvalue); + RDEBUG("Got inner identity \"%pV\"", &t->username->data); if (t->soh) { t->status = PEAP_STATUS_WAIT_FOR_SOH_RESPONSE; RDEBUG2("Requesting SoH from client"); diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c index 1f6ec4a1a3c..a8ce3db16b6 100644 --- a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c +++ b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c @@ -797,7 +797,7 @@ FR_CODE eap_ttls_process(eap_session_t *eap_session, tls_session_t *tls_session) fr_pair_value_bstrncpy(t->username, vp->vp_octets + 5, vp->vp_length - 5); - RDEBUG("Got tunneled identity of %s", t->username->vp_strvalue); + RDEBUG("Got tunneled identity of %pV", &t->username->data); } else { /* * Don't reject the request outright, @@ -867,7 +867,7 @@ FR_CODE eap_ttls_process(eap_session_t *eap_session, tls_session_t *tls_session) int ret; eap_tunnel_data_t *tunnel; - RDEBUG("Tunneled authentication will be proxied to %s", vp->vp_strvalue); + RDEBUG("Tunneled authentication will be proxied to %pV", &vp->data); /* * Tell the original request that it's going diff --git a/src/modules/rlm_ldap/groups.c b/src/modules/rlm_ldap/groups.c index 332ed9af557..98438cba4a8 100644 --- a/src/modules/rlm_ldap/groups.c +++ b/src/modules/rlm_ldap/groups.c @@ -385,7 +385,7 @@ rlm_rcode_t rlm_ldap_cacheable_userobj(rlm_ldap_t const *inst, REQUEST *request, for (vp = fr_pair_cursor_first(&groups_cursor); vp; vp = fr_pair_cursor_next(&groups_cursor)) { - RDEBUG("&control:%s += \"%s\"", inst->cache_da->name, vp->vp_strvalue); + RDEBUG("&control:%s += \"%pV\"", inst->cache_da->name, &vp->data); } } @@ -396,7 +396,7 @@ rlm_rcode_t rlm_ldap_cacheable_userobj(rlm_ldap_t const *inst, REQUEST *request, fr_pair_value_strcpy(vp, *dn_p); fr_pair_cursor_append(&list_cursor, vp); - RDEBUG("&control:%s += \"%s\"", inst->cache_da->name, vp->vp_strvalue); + RDEBUG("&control:%s += \"%pV\"", inst->cache_da->name, &vp->data); ldap_memfree(*dn_p); } REXDENT(); diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index d73cb61e8fe..69d7b0b8a6d 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -591,7 +591,7 @@ static int rlm_ldap_groupcmp(void *instance, REQUEST *request, UNUSED VALUE_PAIR rad_assert(inst->groupobj_base_dn); - RDEBUG("Searching for user in group \"%s\"", check->vp_strvalue); + RDEBUG("Searching for user in group \"%pV\"", &check->data); if (check->vp_length == 0) { REDEBUG("Cannot do comparison (group name is empty)"); @@ -682,7 +682,7 @@ finish: if (conn) mod_conn_release(inst, request, conn); if (!found) { - RDEBUG("User is not a member of \"%s\"", check->vp_strvalue); + RDEBUG("User is not a member of \"%pV\"", &check->data); return 1; } @@ -770,7 +770,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(void *instance, UNUSED void } } - RDEBUG("Login attempt by \"%s\"", request->username->vp_strvalue); + RDEBUG("Login attempt by \"%pV\"", &request->username->data); /* * Get the DN by doing a search. diff --git a/src/modules/rlm_opendirectory/rlm_opendirectory.c b/src/modules/rlm_opendirectory/rlm_opendirectory.c index 08735472526..be6b0fdd1cd 100644 --- a/src/modules/rlm_opendirectory/rlm_opendirectory.c +++ b/src/modules/rlm_opendirectory/rlm_opendirectory.c @@ -329,7 +329,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(UNUSED void *instance, UNUS } if (ret != RLM_MODULE_OK) { - RDEBUG("[%s]: Invalid password", request->username->vp_strvalue); + RDEBUG("Invalid password: %pV", &request->username->data); return ret; } diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index 95b2230e461..286730a3cf9 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -780,7 +780,7 @@ static int sql_groupcmp(void *instance, REQUEST *request, UNUSED VALUE_PAIR *req talloc_free(head); fr_pool_connection_release(inst->pool, request, handle); - RDEBUG("sql_groupcmp finished: User is NOT a member of group %s", check->vp_strvalue); + RDEBUG("sql_groupcmp finished: User is NOT a member of group %pV", &check->data); return 1; } diff --git a/src/unlang/op.c b/src/unlang/op.c index a409a892904..c6e28e3fe82 100644 --- a/src/unlang/op.c +++ b/src/unlang/op.c @@ -1422,13 +1422,8 @@ static unlang_action_t unlang_foreach(REQUEST *request, } #ifndef NDEBUG - if (DEBUG_ENABLED2) { - char buffer[1024]; - - fr_pair_value_snprint(buffer, sizeof(buffer), vp, '"'); - RDEBUG2(""); - RDEBUG2("# looping with: Foreach-Variable-%d = %s", foreach->depth, buffer); - } + RDEBUG2(""); + RDEBUG2("# looping with: Foreach-Variable-%d = %pV", foreach->depth, &vp->data); #endif rad_assert(vp);