diff mbox series

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

Message ID 20240607042615.2069840-3-chengzhihao1@huawei.com
State New
Headers show
Series Add fsck.ubifs support | expand

Commit Message

Zhihao Cheng June 7, 2024, 4:24 a.m. UTC
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>
---
 ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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;