summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2000-03-29 08:24:37 +0000
committerkris <kris@FreeBSD.org>2000-03-29 08:24:37 +0000
commit77771891cbd977cf1e2112dd6e831208deed5e16 (patch)
tree233c8ac65eb86f4a34202f412c79be4370a9dd67 /crypto
parent31c17d386354f8629e8f2750675380e825018a09 (diff)
downloadFreeBSD-src-77771891cbd977cf1e2112dd6e831208deed5e16.zip
FreeBSD-src-77771891cbd977cf1e2112dd6e831208deed5e16.tar.gz
Fix a memory leak.
PR: 17360 Submitted by: Andrew J. Korty <ajk@iu.edu>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/openssh/pam_ssh/pam_ssh.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/crypto/openssh/pam_ssh/pam_ssh.c b/crypto/openssh/pam_ssh/pam_ssh.c
index 19f7722..72c3a4e 100644
--- a/crypto/openssh/pam_ssh/pam_ssh.c
+++ b/crypto/openssh/pam_ssh/pam_ssh.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1999 Andrew J. Korty
+ * Copyright (c) 1999, 2000 Andrew J. Korty
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
#include <sys/param.h>
#include <sys/queue.h>
+#include <sys/stat.h>
#include <fcntl.h>
#include <paths.h>
@@ -120,7 +121,7 @@ env_new(void)
static int
-env_put(ENV *self, char *s)
+env_put(ENV *self, const char *s)
{
struct env_entry *env;
@@ -136,7 +137,7 @@ env_put(ENV *self, char *s)
static void
-env_swap(ENV *self, int which)
+env_swap(const ENV *self, int which)
{
environ = which ? self->e_environ_new : self->e_environ_orig;
}
@@ -173,9 +174,10 @@ env_destroy(ENV *self)
struct env_entry *p;
env_swap(self, 0);
- SLIST_FOREACH(p, &self->e_head, ee_entries) {
+ while ((p = SLIST_FIRST(&self->e_head))) {
free(p->ee_env);
free(p);
+ SLIST_REMOVE_HEAD(&self->e_head, ee_entries);
}
if (self->e_committed)
free(self->e_environ_new);
@@ -365,7 +367,8 @@ pam_sm_open_session(
/* start the agent as the user */
saved_uid = geteuid();
(void)seteuid(pwent->pw_uid);
- env_fp = fopen(env_file, "w");
+ if ((env_fp = fopen(env_file, "w")))
+ (void)chmod(env_file, S_IRUSR);
pipe = popen(PATH_SSH_AGENT, "r");
(void)seteuid(saved_uid);
if (!pipe) {
OpenPOWER on IntegriCloud