]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fixup any log messages which print vp_strvalue directly
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 21 May 2018 09:06:49 +0000 (15:06 +0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 21 May 2018 09:06:49 +0000 (15:06 +0600)
Should use %pV which is binary safe

12 files changed:
src/main/unit_test_module.c
src/main/xlat_func.c
src/modules/rlm_chap/rlm_chap.c
src/modules/rlm_digest/rlm_digest.c
src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c
src/modules/rlm_eap/types/rlm_eap_peap/peap.c
src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c
src/modules/rlm_ldap/groups.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_opendirectory/rlm_opendirectory.c
src/modules/rlm_sql/rlm_sql.c
src/unlang/op.c

index a5837203db34c0cc06a11b5c4d0dde075d1ee599..7e865917e04418ffdbe958dc292f5b2c43eba220 100644 (file)
@@ -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;
        }
index c8c7ec55f8614a0955f2e55aabd8fc340b0e1246..a82b24f959fbc17f6dc3272b71469fc6f34fc6c5 100644 (file)
@@ -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, "<INVALID>"),
                                vp->da->name,
                                vp->tag,
                                fr_int2str(fr_tokens_table, vp->op, "<INVALID>"),
-                               value);
+                               &vp->data);
                } else {
-                       RIDEBUG2("&%s:%s %s %s",
+                       RIDEBUG2("&%s:%s %s %pV",
                                fr_int2str(pair_lists, vpt->tmpl_list, "<INVALID>"),
                                vp->da->name,
                                fr_int2str(fr_tokens_table, vp->op, "<INVALID>"),
-                               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:
index 009f6bd13545c31823c16f6164478ab8cf6d9f9b..d84e64bfe51fec40846ac18ec7130dc683f8857b 100644 (file)
@@ -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;
 }
index bf005589a509dc0be311abc9a458634b922f4e62..57b517bcc1d8375b679971d33240a2684bc173eb 100644 (file)
@@ -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;
                }
        }
index 33685f40b057d61c71bef774ce39701f58b09956..a3dbf9aac5a34f6390a4251a910795d58908573d 100644 (file)
@@ -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.
index 244e104b9bb9c601d52b261fcbd942ec7d3cd6c8..f8f36cda456220e855c02178a217f1332e3307ca 100644 (file)
@@ -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");
index 1f6ec4a1a3cb2c407a7aad7ddf371f4049dd3d49..a8ce3db16b6dfe3238a1cef821b3c9e2069d50bc 100644 (file)
@@ -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
index 332ed9af557d9e1ec70ccfd542afac3fb363d6b4..98438cba4a8b8304e06c9884d9dd27c17a574e21 100644 (file)
@@ -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();
index d73cb61e8fec08b0b1ee462b541d7911d5d45653..69d7b0b8a6d64a49531a6c5e77c05a42ec087f35 100644 (file)
@@ -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.
index 08735472526d40efd0ff48201685a3f594010729..be6b0fdd1cdf6b5926f41e52f2ffcdcf26b79243 100644 (file)
@@ -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;
        }
 
index 95b2230e461206019528f56f844f9690b7809d61..286730a3cf9159e729ffbc567c80fd2f399d54aa 100644 (file)
@@ -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;
 }
index a409a892904fb9b710c665ac00ee13f7a9682614..c6e28e3fe82de880248b4ab0e74554c81028ca15 100644 (file)
@@ -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);