From: Todd C. Miller Date: Sat, 4 Jun 1994 18:39:23 +0000 (+0000) Subject: Initial revision X-Git-Tag: SUDO_1_3_1~197 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa3f3f2b6c516591db7c2c2f15dd8cd20d90858d;p=sudo Initial revision --- diff --git a/strdup.c b/strdup.c new file mode 100644 index 000000000..81265cd8b --- /dev/null +++ b/strdup.c @@ -0,0 +1,78 @@ +/* + * CU sudo version 1.3.1 (based on Root Group sudo version 1.1) + * + * This software comes with no waranty whatsoever, use at your own risk. + * + * Please send bugs, changes, problems to sudo-bugs.cs.colorado.edu + * + */ + +/* + * sudo version 1.1 allows users to execute commands as root + * Copyright (C) 1991 The Root Group, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + ******************************************************************* + * + * This module contains strdup() for those systems without it. + * + * Jeff Nieusma Thu Mar 21 23:11:23 MST 1991 + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif /* lint */ + +#include "config.h" + +#ifdef STDC_HEADERS +#include +#endif /* STDC_HEADERS */ +#ifdef HAVE_STRING_H +#include +#endif /* HAVE_STRING_H */ +#ifdef HAVE_STRINGS_H +#include +#endif /* HAVE_STRINGS_H */ +#ifdef HAVE_MALLOC_H +#include +#endif /* HAVE_MALLOC_H */ + +#ifndef STDC_HEADERS +extern char *malloc(); +extern char *strcpy(); +#endif /* !STDC_HEADERS */ + + +/****************************************************************** + * + * strdup() + * + * this function returns a pointer a string copied into + * a malloc()ed buffer + */ + +char * strdup(s1) + const char * s1; +{ + register char * s; + + if ((s = (char *) malloc(strlen(s1) + 1)) == NULL) + return(NULL); + + (void) strcpy(s, s1); + return(s); +}