From 251a888c629289615498cf5cf60b8a5290d04088 Mon Sep 17 00:00:00 2001 From: Sergio Correia Date: Tue, 5 Mar 2024 17:20:13 +0000 Subject: [PATCH] luks/udisks2: explicitly NULL-terminate buffer Technically, req.data is already NULL-terminated, but let's be explicit about this. Signed-off-by: Sergio Correia --- src/luks/udisks2/clevis-luks-udisks2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/luks/udisks2/clevis-luks-udisks2.c b/src/luks/udisks2/clevis-luks-udisks2.c index 023c098d..3a520d59 100644 --- a/src/luks/udisks2/clevis-luks-udisks2.c +++ b/src/luks/udisks2/clevis-luks-udisks2.c @@ -591,6 +591,9 @@ main(int argc, char *const argv[]) req.used = recv(pair[0], req.data, sizeof(req.data), 0); if (req.used < 1 || req.data[req.used - 1]) break; + /* Technically, req.data is already NULL-terminated, but let's + * be explicit. */ + req.data[req.used - 1] = '\0'; if (crypt_init(&cd, req.data) < 0) goto next;