From b1e446f59e50c03d88015b6cb078fb65bec7d77e Mon Sep 17 00:00:00 2001 From: Christian Göttsche Date: Thu, 4 Jan 2024 17:46:38 +0100 Subject: libpamc/test: pipe deallocation mismatch Close pipes opened via popen(3) with pclose(3). Also close the pipe in error branches. Reported by cppcheck. --- libpamc/test/modules/pam_secret.c | 4 +++- libpamc/test/regress/test.libpamc.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'libpamc') diff --git a/libpamc/test/modules/pam_secret.c b/libpamc/test/modules/pam_secret.c index 2fe7066c..12215359 100644 --- a/libpamc/test/modules/pam_secret.c +++ b/libpamc/test/modules/pam_secret.c @@ -123,15 +123,17 @@ int create_digest(const char *d1, const char *d2, const char *d3, if (fgets(buffer_33, 33, pipe) == NULL) { D(("failed to read digest")); + pclose(pipe); return 0; } if (strlen(buffer_33) != 32) { D(("digest was not 32 chars")); + pclose(pipe); return 0; } - fclose(pipe); + pclose(pipe); D(("done [%s]", buffer_33)); diff --git a/libpamc/test/regress/test.libpamc.c b/libpamc/test/regress/test.libpamc.c index 4251b4fa..e6d6bb3f 100644 --- a/libpamc/test/regress/test.libpamc.c +++ b/libpamc/test/regress/test.libpamc.c @@ -153,7 +153,7 @@ char *create_digest(int length, const char *raw) exit(1); } - fclose(pipe); + pclose(pipe); return temp_packet.buffer; } -- cgit v1.2.3