commit d927fd07c18c42f10c22ca03b51cb09220e322da
parent 8dff156eb69e172961f9da1080b9ae538dce0061
Author: James Prestwood <prestwoj@gmail.com>
Date: Wed, 16 Apr 2025 10:33:42 -0700
storage: add length check in __storage_decrypt
The length of EncryptedSecurity was assumed to be at least 16 bytes
and anything less would underflow the length to l_malloc.
Fixes: 01cd8587606b ("storage: implement network profile encryption")
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/storage.c b/src/storage.c
@@ -501,6 +501,13 @@ int __storage_decrypt(struct l_settings *settings, const char *ssid,
}
/*
+ * It should likely be far larger than this, but that will get caught
+ * later when reloading the decrypted data.
+ */
+ if (elen < 16)
+ return -EBADMSG;
+
+ /*
* AES-SIV automatically verifies the IV (16 bytes) and returns only
* the decrypted data portion. We add one here for the NULL terminator
* since this is always going to be textual data after decryption.