From b422e3c31691412f0a5404d09f7b328477e23c48 Mon Sep 17 00:00:00 2001 From: Skyler Ferrante Date: Tue, 30 May 2023 15:00:12 -0400 Subject: [PATCH] Check if crypt_method null before dereferencing Make sure crypto_method set before sha-rounds. Only affects newusers. --- src/newusers.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/newusers.c b/src/newusers.c index ae2224fc..d6b7c3c3 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -662,6 +662,13 @@ static void process_flags (int argc, char **argv) case 's': sflg = true; bad_s = 0; + + if (!crypt_method){ + fprintf(stderr, + _("%s: Provide '--crypt-method'\n"), + Prog); + usage (EXIT_FAILURE); + } #if defined(USE_SHA_CRYPT) if ( ( ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512"))) && (0 == getlong(optarg, &sha_rounds)))) { -- 2.27.0