mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zkey: Fix possible out of bounds access with malformed property files
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 <fcallies@linux.ibm.com> Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
c953486dec
commit
c7ab70df2c
@@ -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] == '#')
|
||||
|
||||
Reference in New Issue
Block a user