]> www.infradead.org Git - mtd-utils.git/commitdiff
mkfs.ubifs: Initialize 'cipher_name' as NULL
authorZhihao Cheng <chengzhihao1@huawei.com>
Sun, 4 Feb 2024 02:21:44 +0000 (10:21 +0800)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Wed, 25 Sep 2024 07:08:41 +0000 (09:08 +0200)
Variable 'cipher_name' is defined on stack without initialization, when
an user invokes mkfs with '--key' and without '-C', 'cipher_name' is a
random value, which could cause init_fscrypt_context() failed to find a
valid cipher.
Fix it by initializing 'cipher_name' as NULL when it is declared.

Fixes: cc4c5e295f546 ("mkfs.ubifs: Enable support for building without crypto")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
ubifs-utils/mkfs.ubifs/mkfs.ubifs.c

index 5ca015128e335996c5f3dbe429e8f19659f378d8..b91a3e2df4d34aaf32a3906a8b1149b40ead22f1 100644 (file)
@@ -556,7 +556,7 @@ static int get_options(int argc, char**argv)
        struct stat st;
        char *endp;
 #ifdef WITH_CRYPTO
-       const char *cipher_name;
+       const char *cipher_name = NULL;
 #endif
 
        c->fanout = 8;