From c8c85ca0b3cbb41f8783167331a345539deac0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 3 Aug 2018 16:11:43 +0200 Subject: [PATCH] Conceal debugging printf()s. --- sbin/otpradiusd/radius.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sbin/otpradiusd/radius.c b/sbin/otpradiusd/radius.c index a0cb7b5..93759a8 100644 --- a/sbin/otpradiusd/radius.c +++ b/sbin/otpradiusd/radius.c @@ -301,7 +301,7 @@ rad_decode_str(const rad_attribute *ra, const uint8_t **str, size_t *len) return (0); } - +#if DEBUG_PRINTF static void mxu(md5_ctx *context, const void *data, unsigned int len) { @@ -315,6 +315,7 @@ mxu(md5_ctx *context, const void *data, unsigned int len) } #undef md5_update #define md5_update mxu +#endif static int handle_access_request(rad_transaction *rx) @@ -325,8 +326,6 @@ handle_access_request(rad_transaction *rx) uint8_t *nextra, *end; const uint8_t *user, *pass; size_t userlen, passlen; - unsigned int i; - int ch; req = &rx->request; rsp = &rx->response; @@ -380,31 +379,35 @@ handle_access_request(rad_transaction *rx) warnx("mssing User-Name attribute"); return (0); } +#if DEBUG_PRINTF fprintf(stderr, "user: \""); - for (i = 0; i < userlen; ++i) { - ch = user[i]; + for (unsigned int i = 0; i < userlen; ++i) { + int ch = user[i]; if (ch >= 32 && ch < 127 && ch != '"') fprintf(stderr, "%c", ch); else fprintf(stderr, "\\x%02x", ch); } fprintf(stderr, "\"\n"); +#endif if (pass == NULL) { warnx("missing User-Password attribute"); return (0); } - fprintf(stderr, "pass: \""); auth_decode(req->authenticator, pass, password, passlen); while (password[passlen - 1] == '\0') passlen--; - for (i = 0; i < passlen; ++i) { - ch = password[i]; +#if DEBUG_PRINTF + fprintf(stderr, "pass: \""); + for (unsigned int i = 0; i < passlen; ++i) { + int ch = password[i]; if (ch >= 32 && ch < 127 && ch != '"') fprintf(stderr, "%c", ch); else fprintf(stderr, "\\x%02x", ch); } fprintf(stderr, "\"\n"); +#endif static int coin; if ((coin = !coin)) {