KEYS: encrypted: Add check for strsep
authorChen Ni <nichen@iscas.ac.cn>
Wed, 8 Nov 2023 07:36:27 +0000 (07:36 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:14 +0000 (15:35 -0800)
[ Upstream commit b4af096b5df5dd131ab796c79cedc7069d8f4882 ]

Add check for strsep() in order to transfer the error.

Fixes: cd3bc044af48 ("KEYS: encrypted: Instantiate key with user-provided decrypted data")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/keys/encrypted-keys/encrypted.c

index 1e31398..fea7e09 100644 (file)
@@ -237,6 +237,10 @@ static int datablob_parse(char *datablob, const char **format,
                        break;
                }
                *decrypted_data = strsep(&datablob, " \t");
+               if (!*decrypted_data) {
+                       pr_info("encrypted_key: decrypted_data is missing\n");
+                       break;
+               }
                ret = 0;
                break;
        case Opt_load: