[RFC PATCH mtd-utils 002/110] mkfs.ubifs: Initialize 'cipher_name' as NULL

From: Zhihao Cheng
Date: Fri Jun 07 2024 - 00:26:48 EST


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@xxxxxxxxxx>
---
ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 5ca01512..b91a3e2d 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -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;
--
2.13.6