From c7ab70df2cfce2a54c10e4fe94ee1824f0b4e3ef Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Thu, 11 Jun 2026 17:42:21 +0200 Subject: [PATCH] zkey: Fix possible out of bounds access with malformed property files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When reading a properties file with a line containing a binary zero as first character, an array access at index -1 is attempted, because strlen considers this as an empty string (len = 0). The following array access 'line[len - 1]' accesses the array at index -1. Fix this by checking the line length and skip empty lines. Reviewed-by: Finn Callies Signed-off-by: Ingo Franzki Signed-off-by: Jan Höppner --- zkey/properties.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zkey/properties.c b/zkey/properties.c index 09d8c014..4da5de84 100644 --- a/zkey/properties.c +++ b/zkey/properties.c @@ -386,6 +386,8 @@ int properties_load(struct properties *properties, const char *filename, while (fgets(line, sizeof(line), fp) != NULL) { len = strlen(line); + if (len == 0) + continue; if (line[len - 1] == '\n') line[len - 1] = '\0'; if (line[0] == '#')