aboutsummaryrefslogtreecommitdiff
path: root/libpamc
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2024-01-04 17:46:38 +0100
committerChristian Göttsche <cgzones@googlemail.com>2024-01-04 17:46:38 +0100
commitb1e446f59e50c03d88015b6cb078fb65bec7d77e (patch)
tree365ddb122b727ae60444f0283f563160498d92d2 /libpamc
parent9893308eb4be8baadf94c347eaf04610018d9223 (diff)
downloadpam-b1e446f59e50c03d88015b6cb078fb65bec7d77e.tar.gz
pam-b1e446f59e50c03d88015b6cb078fb65bec7d77e.tar.bz2
pam-b1e446f59e50c03d88015b6cb078fb65bec7d77e.zip
libpamc/test: pipe deallocation mismatch
Close pipes opened via popen(3) with pclose(3). Also close the pipe in error branches. Reported by cppcheck.
Diffstat (limited to 'libpamc')
-rw-r--r--libpamc/test/modules/pam_secret.c4
-rw-r--r--libpamc/test/regress/test.libpamc.c2
2 files changed, 4 insertions, 2 deletions
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;
}