All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KEYS: fix memory leak when reading certificate fails
@ 2022-03-03  8:15 Denis Glazkov
  2022-03-03 12:02 ` Dongliang Mu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Denis Glazkov @ 2022-03-03  8:15 UTC (permalink / raw)
  Cc: Denis Glazkov, David Howells, Jarkko Sakkinen, James Morris,
	Serge E. Hallyn, Mimi Zohar, Mehmet Kayaalp, linux-kernel,
	keyrings, linux-security-module

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")
Signed-off-by: Denis Glazkov <d.glazkov@omp.ru>
---
 scripts/insert-sys-cert.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836c2342..b98a0b12f16f 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -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);
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] KEYS: fix memory leak when reading certificate fails
@ 2022-02-24 20:04 Denis Glazkov
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Glazkov @ 2022-02-24 20:04 UTC (permalink / raw)
  Cc: Denis Glazkov, Mehmet Kayaalp, Mimi Zohar, David Howells, linux-kernel

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")
Signed-off-by: Denis Glazkov <d.glazkov@omp.ru>
---
 scripts/insert-sys-cert.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836c2342..b98a0b12f16f 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -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);
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-30 15:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03  8:15 [PATCH] KEYS: fix memory leak when reading certificate fails Denis Glazkov
2022-03-03 12:02 ` Dongliang Mu
2022-03-03 12:56 ` [PATCH v2] KEYS: fix memory leaks when reading certificate Denis Glazkov
2022-03-30 15:37 ` David Howells
  -- strict thread matches above, loose matches on Subject: below --
2022-02-24 20:04 [PATCH] KEYS: fix memory leak when reading certificate fails Denis Glazkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.