summaryrefslogtreecommitdiff
path: root/libpam_misc/help_env.c
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2005-09-20 08:31:27 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2005-09-20 08:31:27 +0000
commitcff33b6413b03978d6289542f9aec790f0785783 (patch)
tree34abf1d042d90229f84c4bd1590f9488cf6d4806 /libpam_misc/help_env.c
parentccfa4297f4081a42919afd793a615d09b965442c (diff)
Relevant BUGIDs: none
Purpose of commit: bugfix Commit summary: --------------- Fix missing NULL pointer check and us asprintf instead of malloc/snprintf (from Dmitry V. Levin).
Diffstat (limited to 'libpam_misc/help_env.c')
-rw-r--r--libpam_misc/help_env.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libpam_misc/help_env.c b/libpam_misc/help_env.c
index 2b800283..601c5f41 100644
--- a/libpam_misc/help_env.c
+++ b/libpam_misc/help_env.c
@@ -5,6 +5,8 @@
*
*/
+#include "config.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -72,9 +74,7 @@ int pam_misc_setenv(pam_handle_t *pamh, const char *name
return PAM_PERM_DENIED; /* not allowed to overwrite */
}
}
- tmp = malloc(2+strlen(name)+strlen(value));
- if (tmp != NULL) {
- sprintf(tmp,"%s=%s",name,value);
+ if (asprintf(&tmp, "%s=%s", name, value) >= 0) {
D(("pam_putt()ing: %s", tmp));
retval = pam_putenv(pamh, tmp);
_pam_overwrite(tmp); /* purge */