lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 15 May 2024 11:27:50 -0700
From: Samasth Norway Ananda <samasth.norway.ananda@...cle.com>
To: namhyung@...nel.org, acme@...nel.org
Cc: peterz@...radead.org, mingo@...hat.com, mark.rutland@....com,
        alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
        irogers@...gle.com, adrian.hunter@...el.com,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        samasth.norway.ananda@...cle.com
Subject: [PATCH RESEND] perf test pmu: Fix file Leak in test_format_dir_get

File is opened inside the for loop. But if the 'if' condition is
successful then 'break' statement will be reached, exiting the
'for' loop prior to reaching 'fclose'.

Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@...cle.com>
---
Found this error through static analysis. This has only been compile
tested.
---
 tools/perf/tests/pmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
index 8f18127d876a..f751e6cb6ac0 100644
--- a/tools/perf/tests/pmu.c
+++ b/tools/perf/tests/pmu.c
@@ -106,8 +106,10 @@ static char *test_format_dir_get(char *dir, size_t sz)
 		if (!file)
 			return NULL;
 
-		if (1 != fwrite(format->value, strlen(format->value), 1, file))
+		if (1 != fwrite(format->value, strlen(format->value), 1, file)) {
+			fclose(file);
 			break;
+		}
 
 		fclose(file);
 	}
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ