]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
various bug fixes in rlm_mschap
authorAlan T. DeKok <aland@freeradius.org>
Thu, 26 Feb 2026 19:31:37 +0000 (14:31 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 26 Feb 2026 20:09:36 +0000 (15:09 -0500)
src/modules/rlm_mschap/opendir.c
src/modules/rlm_mschap/rlm_mschap.c

index fad1cf22e3f69d70e20ea3495c5bd4ad296882f1..44b0a1fbfba6f2ec6cb8be08fb893740880ee0e4 100644 (file)
@@ -240,7 +240,6 @@ DIAG_OFF(array-bounds)
 unlang_action_t od_mschap_auth(unlang_result_t *p_result, request_t *request, fr_pair_t *challenge, fr_pair_t *usernamepair,
                               mschap_auth_call_env_t *env_data)
 {
-       rlm_rcode_t             rcode            = RLM_MODULE_OK;
        tDirStatus              status           = eDSNoErr;
        tDirReference           dsRef            = 0;
        tDirNodeReference       userNodeRef      = 0;
@@ -270,16 +269,16 @@ unlang_action_t od_mschap_auth(unlang_result_t *p_result, request_t *request, fr
                RETURN_UNLANG_FAIL;
        }
 
-       getUserNodeRef(p_result, request, username_string, &short_user_name, &userNodeRef, dsRef);
-       if (rcode != RLM_MODULE_OK) {
-               if (rcode != RLM_MODULE_NOOP) {
+       (void) getUserNodeRef(p_result, request, username_string, &short_user_name, &userNodeRef, dsRef);
+       if (p_result->rcode != RLM_MODULE_OK) {
+               if (p_result->rcode != RLM_MODULE_NOOP) {
                        RDEBUG2("od_mschap_auth: getUserNodeRef() failed");
                }
                if (username_string != NULL)
                        talloc_free(username_string);
                if (dsRef != 0)
                        dsCloseDirService(dsRef);
-               RETURN_UNLANG_RCODE(rcode);
+               return UNLANG_ACTION_CALCULATE_RESULT;
        }
 
        /* We got a node; fill the stepBuffer
index b2985ee7a548166c39760d65825da012a375f310..168ed18d16c0d40693f792f471a06573bd0d3748 100644 (file)
@@ -951,7 +951,7 @@ static int CC_HINT(nonnull) do_mschap_cpw(rlm_mschap_t const *inst, request_t *r
                /*
                 *  Read from the child
                 */
-               len = radius_readfrom_program_legacy(from_child, pid, fr_time_delta_from_sec(10), buf, sizeof(buf));
+               len = radius_readfrom_program_legacy(from_child, pid, fr_time_delta_from_sec(10), buf, sizeof(buf) - 1);
                if (len < 0) {
                        /* radius_readfrom_program_legacy will have closed from_child for us */
                        REDEBUG("Failure reading from child");
@@ -2072,18 +2072,21 @@ static int mschap_new_pass_decrypt(request_t *request, mschap_auth_ctx_t *auth_c
        MEM(evp_ctx = EVP_CIPHER_CTX_new());
 
        if (unlikely(EVP_EncryptInit_ex(evp_ctx, EVP_rc4(), NULL, auth_ctx->nt_password->vp_octets, NULL) != 1)) {
+               EVP_CIPHER_CTX_free(evp_ctx);
                fr_tls_strerror_printf(NULL);
                RPERROR("Failed initialising RC4 ctx");
                return -1;
        }
 
        if (unlikely(EVP_CIPHER_CTX_set_key_length(evp_ctx, auth_ctx->nt_password->vp_length)) != 1) {
+               EVP_CIPHER_CTX_free(evp_ctx);
                fr_tls_strerror_printf(NULL);
                RPERROR("Failed setting key length");
                return -1;
        }
 
        if (unlikely(EVP_EncryptUpdate(evp_ctx, nt_pass_decrypted, &ntlen, auth_ctx->cpw_ctx->new_nt_encrypted, ntlen) != 1)) {
+               EVP_CIPHER_CTX_free(evp_ctx);
                fr_tls_strerror_printf(NULL);
                RPERROR("Failed ingesting new password");
                return -1;