From 632dffe99cc8e3aefb4410aec2a3091df48a6f46 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Thu, 6 Dec 2007 20:20:07 +0000 Subject: Relevant BUGIDs: Purpose of commit: new feature Commit summary: --------------- 2007-12-06 Eamon Walsh * 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. --- libpam/pam_misc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libpam/pam_misc.c') 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) */ -- cgit v1.2.3