Skip to contentSkip to conversation

KEYS: fix memory leak when reading certificate fails

PATCH New Denis Glazkov 1 participant 1 message Feb 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KEYS: fix memory leak when reading certificate fails

In the read_file function of insert-sys-cert.c script, if the data is read incorrectly, the memory allocated for the buf array is not freed.

Fixes c4c361059585 ("KEYS: Reserve an extra certificate symbol for inserting without recompiling")
---
 scripts/insert-sys-cert.c | 1 +
 1 file changed, 1 insertion(+)
scripts/insert-sys-cert.c +1 -0
index 8902836c2342..b98a0b12f16f 100644
@@ -251,6 +251,7 @@ static char *read_file(char *file_name, int *size)
 	if (read(fd, buf, *size) != *size) {
 		perror("File read failed");
 		close(fd);
+		free(buf);
 		return NULL;
 	}
 	close(fd);
Signature · 1 line
2.25.1