summaryrefslogtreecommitdiff
path: root/libpam/pam_misc.c
diff options
context:
space:
mode:
authorTomas Mraz <tm@t8m.info>2007-12-06 20:20:07 +0000
committerTomas Mraz <tm@t8m.info>2007-12-06 20:20:07 +0000
commit632dffe99cc8e3aefb4410aec2a3091df48a6f46 (patch)
treea143da18fc11f9f9dbec7a9f514ea9bec110bcad /libpam/pam_misc.c
parent337e34ff7407327700ae3ddf2bdda00698386e13 (diff)
Relevant BUGIDs:
Purpose of commit: new feature Commit summary: --------------- 2007-12-06 Eamon Walsh <ewalsh@tycho.nsa.gov> * libpam/include/security/_pam_macros.h: Add _pam_overwrite_n() macro. * libpam/include/security/_pam_types.h: Add PAM_XDISPLAY, PAM_XAUTHDATA items, pam_xauth_data struct. * libpam/pam_item.c (pam_set_item, pam_get_item): Handle PAM_XDISPLAY and PAM_XAUTHDATA items. * libpam/pam_end.c (pam_end): Destroy the new items. * libpam/pam_private.h (pam_handle): Add data members for new items. Add prototype for _pam_memdup. * libpam/pam_misc.c: Add _pam_memdup. * doc/man/Makefile.am: Add pam_xauth_data.3. Replace pam_item_types.inc.xml with pam_item_types_std.inc.xml and pam_item_types_ext.inc.xml. * doc/man/pam_get_item.3.xml: Replace pam_item_types.inc.xml with pam_item_types_std.inc.xml and pam_item_types_ext.inc.xml. * doc/man/pam_set_item.3.xml: Likewise. * doc/man/pam_item_types.inc.xml: Removed file. * doc/man/pam_item_types_ext.inc.xml: New file. * doc/man/pam_item_types_std.inc.xml: New file.
Diffstat (limited to 'libpam/pam_misc.c')
-rw-r--r--libpam/pam_misc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpam/pam_misc.c b/libpam/pam_misc.c
index 770c9cce..574a570e 100644
--- a/libpam/pam_misc.c
+++ b/libpam/pam_misc.c
@@ -137,6 +137,28 @@ char *_pam_strdup(const char *x)
return new; /* return the duplicate or NULL on error */
}
+/*
+ * Safe duplication of memory buffers. "Paranoid"; don't leave
+ * evidence of old token around for later stack analysis.
+ */
+
+char *_pam_memdup(const char *x, int len)
+{
+ register char *new=NULL;
+
+ if (x != NULL) {
+ if ((new = malloc(len)) == NULL) {
+ len = 0;
+ pam_syslog(NULL, LOG_CRIT, "_pam_memdup: failed to get memory");
+ } else {
+ memcpy (new, x, len);
+ }
+ x = NULL;
+ }
+
+ return new; /* return the duplicate or NULL on error */
+}
+
/* Generate argv, argc from s */
/* caller must free(argv) */