From 0f1054be1f61dbb54dc57a1e0bfe286dedfc6a52 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Mon, 26 Jan 2015 22:04:08 -0500 Subject: [PATCH] Rearrange code to quiet cppcheck --- src/modules/rlm_digest/rlm_digest.c | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/modules/rlm_digest/rlm_digest.c b/src/modules/rlm_digest/rlm_digest.c index f190d17..d3c81c8 100644 --- a/src/modules/rlm_digest/rlm_digest.c +++ b/src/modules/rlm_digest/rlm_digest.c @@ -402,37 +402,37 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(UNUSED void *instance, REQU * QOP is "auth-int", tack on ": Digest-Body-Digest" */ qop = pairfind(request->packet->vps, PW_DIGEST_QOP, 0, TAG_ANY); - if ((qop != NULL) && - (strcasecmp(qop->vp_strvalue, "auth-int") == 0)) { - VALUE_PAIR *body; + if (qop) { + if (strcasecmp(qop->vp_strvalue, "auth-int") == 0) { + VALUE_PAIR *body; - /* - * Add in Digest-Body-Digest - */ - a2[a2_len] = ':'; - a2_len++; + /* + * Add in Digest-Body-Digest + */ + a2[a2_len] = ':'; + a2_len++; - /* - * Must be a hex representation of an MD5 digest. - */ - body = pairfind(request->packet->vps, PW_DIGEST_BODY_DIGEST, 0, TAG_ANY); - if (!body) { - REDEBUG("No Digest-Body-Digest: Cannot perform Digest authentication"); - return RLM_MODULE_INVALID; - } + /* + * Must be a hex representation of an MD5 digest. + */ + body = pairfind(request->packet->vps, PW_DIGEST_BODY_DIGEST, 0, TAG_ANY); + if (!body) { + REDEBUG("No Digest-Body-Digest: Cannot perform Digest authentication"); + return RLM_MODULE_INVALID; + } - if ((a2_len + body->vp_length) > sizeof(a2)) { - REDEBUG("Digest-Body-Digest is too long"); - return RLM_MODULE_INVALID; - } + if ((a2_len + body->vp_length) > sizeof(a2)) { + REDEBUG("Digest-Body-Digest is too long"); + return RLM_MODULE_INVALID; + } - memcpy(a2 + a2_len, body->vp_octets, body->vp_length); - a2_len += body->vp_length; + memcpy(a2 + a2_len, body->vp_octets, body->vp_length); + a2_len += body->vp_length; - } else if ((qop != NULL) && - (strcasecmp(qop->vp_strvalue, "auth") != 0)) { - REDEBUG("Unknown Digest-QOP \"%s\": Cannot perform Digest authentication", qop->vp_strvalue); - return RLM_MODULE_INVALID; + } else if (strcasecmp(qop->vp_strvalue, "auth") != 0) { + REDEBUG("Unknown Digest-QOP \"%s\": Cannot perform Digest authentication", qop->vp_strvalue); + return RLM_MODULE_INVALID; + } } a2[a2_len] = '\0'; -- 2.1.4