aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2000-03-29 08:24:37 +0000
committerKris Kennaway <kris@FreeBSD.org>2000-03-29 08:24:37 +0000
commite31adaffd99bdeaf0faeec9c17bd4cb17fc987d1 (patch)
tree8407c9604478c61a5c39f247d5aa87a7601c571f /crypto
parentf72d9d83f5c299f88d63ac6e201a82270fd2c5a2 (diff)
downloadsrc-e31adaffd99bdeaf0faeec9c17bd4cb17fc987d1.tar.gz
src-e31adaffd99bdeaf0faeec9c17bd4cb17fc987d1.zip
Fix a memory leak.
PR: 17360 Submitted by: Andrew J. Korty <ajk@iu.edu>
Notes
Notes: svn path=/head/; revision=58772
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 19f7722af4eb..72c3a4e8fd70 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) {