1 /* $FreeBSD: src/contrib/libpam/libpam_misc/xstrdup.c,v 1.2.6.2 2001/06/11 15:28:15 markm Exp $ */
2 /* $DragonFly: src/contrib/libpam/libpam_misc/Attic/xstrdup.c,v 1.2 2003/06/17 04:24:03 dillon Exp $ */
3 /* $Header: /home/morgan/pam/Linux-PAM-0.53/libpam_misc/RCS/xstrdup.c,v 1.4 1996/11/10 20:10:56 morgan Exp $ */
7 * Revision 1.4 1996/11/10 20:10:56 morgan
8 * modification for stack paranoia
13 #include <security/pam_misc.h>
16 * Safe duplication of character strings. "Paranoid"; don't leave
17 * evidence of old token around for later stack analysis.
20 char *xstrdup(const char *x)
22 register char *new=NULL;
27 for (i=0; x[i]; ++i); /* length of string */
28 if ((new = malloc(++i)) == NULL) {
38 return new; /* return the duplicate or NULL on error */