From 05b737b37fc57781b327b7e294cee0028780bb58 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 20 Aug 2024 17:29:16 +1000 Subject: [PATCH] pppd: Make sure we don't return an initialized CHAP Response length If anything goes wrong in preparing a CHAP Response, return a 0-length response instead of leaving the length field uninitialized. Also print a warning message to say that something went wrong. Signed-off-by: Paul Mackerras --- pppd/chap-md5.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pppd/chap-md5.c b/pppd/chap-md5.c index d9259d2..b928ce9 100644 --- a/pppd/chap-md5.c +++ b/pppd/chap-md5.c @@ -112,6 +112,7 @@ chap_md5_make_response(unsigned char *response, int id, char *our_name, int challenge_len = *challenge++; int hash_len = MD5_DIGEST_LENGTH; + response[0] = 0; PPP_MD_CTX* ctx = PPP_MD_CTX_new(); if (ctx) { @@ -133,6 +134,8 @@ chap_md5_make_response(unsigned char *response, int id, char *our_name, } PPP_MD_CTX_free(ctx); } + if (response[0] == 0) + warn("Error occurred in preparing CHAP-Response"); } static struct chap_digest_type md5_digest = { -- 2.39.5