From ec4161186e51b55d4faaa394dc4607200cb30f68 Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Thu, 24 Oct 2024 12:18:17 +0200 Subject: [PATCH] ima_boot_aggregate: TBROK on fread() failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fread() should read 1 byte, quit when it fails it. This fixes warning: ignoring return value of ‘fread’ declared with attribute ‘warn_unused_result’ [-Wunused-result]. Link: https://lore.kernel.org/ltp/20241101143726.1278291-2-pvorel@suse.cz/ Signed-off-by: Petr Vorel --- .../kernel/security/integrity/ima/src/ima_boot_aggregate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c b/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c index 68d12fc3c2f..420b0c736d3 100644 --- a/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c +++ b/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c @@ -116,7 +116,8 @@ static void do_test(void) break; } #endif - fread(event.data, event.header.len, 1, fp); + if (fread(event.data, event.header.len, 1, fp) != 1) + tst_brk(TBROK, "failed to read 1 byte"); } SAFE_FCLOSE(fp);