]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Check if crypt_method null before dereferencing
authorSkyler Ferrante <sjf5462@rit.edu>
Tue, 30 May 2023 19:00:12 +0000 (15:00 -0400)
committerGitHub <noreply@github.com>
Tue, 30 May 2023 19:00:12 +0000 (14:00 -0500)
Make sure crypto_method set before sha-rounds. Only affects newusers.

src/newusers.c

index ae2224fce31e3f739991caccf344e1328ad4e5a3..d6b7c3c34c47fa183b0014be66019c312d8bed8f 100644 (file)
@@ -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)))) {