From efd31890b5ed496a5a00c08a262da240e66a4ddc Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Thu, 3 Jan 2019 12:44:11 -0800 Subject: New upstream version 0.76 --- Linux-PAM/libpam_misc/xstrdup.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Linux-PAM/libpam_misc/xstrdup.c (limited to 'Linux-PAM/libpam_misc/xstrdup.c') diff --git a/Linux-PAM/libpam_misc/xstrdup.c b/Linux-PAM/libpam_misc/xstrdup.c new file mode 100644 index 00000000..f5bfde66 --- /dev/null +++ b/Linux-PAM/libpam_misc/xstrdup.c @@ -0,0 +1,31 @@ +/* $Id: xstrdup.c,v 1.1.1.1 2001/04/29 04:17:12 hartmans Exp $ */ + +#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.2.3