[PATCH] kexec-tools: fix leak FILE pointer.
Lichen Liu
lichliu at redhat.com
Wed Mar 30 04:09:51 PDT 2022
Close fp if file size is smaller than 13 bytes.
Signed-off-by: Lichen Liu <lichliu at redhat.com>
---
kexec/lzma.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kexec/lzma.c b/kexec/lzma.c
index f27cfe2..2fc07e6 100644
--- a/kexec/lzma.c
+++ b/kexec/lzma.c
@@ -170,8 +170,11 @@ int is_lzma_file(const char *filename)
const size_t size = fread(buf, 1, sizeof(buf), fp);
- if (size != 13)
+ if (size != 13) {
+ /* file is too small to be a lzma file. */
+ fclose(fp);
return 0;
+ }
lzma_filter filter = { .id = LZMA_FILTER_LZMA1 };
--
2.27.0
More information about the kexec
mailing list