From 36805fe6ba339a02fa177467f753604d8cbf7b15 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Wed, 30 Mar 2022 19:09:51 +0800 Subject: kexec-tools: fix leak FILE pointer. Close fp if file size is smaller than 13 bytes. Fixes: dcfcc73c73e6 ("kexec-tools: Determine if the image is lzma commpressed") Signed-off-by: Lichen Liu Signed-off-by: Simon Horman --- kexec/lzma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec/lzma.c b/kexec/lzma.c index f27cfe24..2fc07e6c 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 }; -- cgit 1.2.3-korg