From f06b122f95ed96a1a451b0939f85cdb39cd631e0 Mon Sep 17 00:00:00 2001 From: jdp Date: Wed, 18 Nov 1998 01:16:21 +0000 Subject: Initial import of virgin Linux-PAM 0.65, slightly stripped down. --- contrib/libpam/libpam_misc/xstrdup.c | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 contrib/libpam/libpam_misc/xstrdup.c (limited to 'contrib/libpam/libpam_misc/xstrdup.c') diff --git a/contrib/libpam/libpam_misc/xstrdup.c b/contrib/libpam/libpam_misc/xstrdup.c new file mode 100644 index 0000000..e54a87d --- /dev/null +++ b/contrib/libpam/libpam_misc/xstrdup.c @@ -0,0 +1,38 @@ +/* $Header: /home/morgan/pam/Linux-PAM-0.53/libpam_misc/RCS/xstrdup.c,v 1.4 1996/11/10 20:10:56 morgan Exp $ */ + +/* + * $Log: xstrdup.c,v $ + * Revision 1.4 1996/11/10 20:10:56 morgan + * modification for stack paranoia + * + */ + +#include +#include +#include + +/* + * Safe duplication of character strings. "Paranoid"; don't leave + * evidence of old token around for later stack analysis. + */ + +char *xstrdup(const char *x) +{ + register char *new=NULL; + + if (x != NULL) { + register int i; + + for (i=0; x[i]; ++i); /* length of string */ + if ((new = malloc(++i)) == NULL) { + i = 0; + } else { + while (i-- > 0) { + new[i] = x[i]; + } + } + x = NULL; + } + + return new; /* return the duplicate or NULL on error */ +} -- cgit v1.1