string/strcpy/strtcpy.h \
string/strdup/strndupa.c \
string/strdup/strndupa.h \
+ string/strdup/xstrdup.c \
+ string/strdup/xstrdup.h \
string/strdup/xstrndup.c \
string/strdup/xstrndup.h \
string/strftime.c \
-/*
- * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
- * SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz
- * SPDX-FileCopyrightText: 2003 - 2006, Tomasz Kłoczko
- * SPDX-FileCopyrightText: 2008 , Nicolas François
- * SPDX-FileCopyrightText: 2023 , Alejandro Colomar <alx@kernel.org>
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
+// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
+// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
+// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
+// SPDX-FileCopyrightText: 2008 , Nicolas François
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
/* Replacements for malloc and strdup with error checking. Too trivial
to be worth copyrighting :-). I did that because a lot of code used
#include <config.h>
-#ident "$Id$"
-
#include "alloc.h"
#include <errno.h>
extern inline void *xmallocarray(size_t nmemb, size_t size);
extern inline void *mallocarray(size_t nmemb, size_t size);
extern inline void *reallocarrayf(void *p, size_t nmemb, size_t size);
-extern inline char *xstrdup(const char *str);
void *
#include <stdlib.h>
#include "attr.h"
-#include "defines.h"
#define CALLOC(n, type) ((type *) calloc(n, sizeof(type)))
inline void *mallocarray(size_t nmemb, size_t size);
ATTR_MALLOC(free)
inline void *reallocarrayf(void *p, size_t nmemb, size_t size);
-ATTR_MALLOC(free)
-inline char *xstrdup(const char *str);
ATTR_MALLOC(free)
void *xcalloc(size_t nmemb, size_t size);
}
-inline char *
-xstrdup(const char *str)
-{
- return strcpy(XMALLOC(strlen(str) + 1, char), str);
-}
-
-
#endif // include guard
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strdup/xstrdup.h"
/*
#include "alloc.h"
#include "prototypes.h"
#include "defines.h"
+#include "string/strdup/xstrdup.h"
+
+
/*
* add_list - add a member to a list of group members
*
#include <stdio.h>
-#include "alloc.h"
#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
+#include "string/strdup/xstrdup.h"
+
+
/*
* motd -- output the /etc/motd file
*
#include <ctype.h>
#include <stdio.h>
-#include "alloc.h"
#include "attr.h"
#include "memzero.h"
#include "prototypes.h"
#include "defines.h"
#include "getdef.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strdup/xstrdup.h"
+
#if WITH_LIBBSD == 0
#include "freezero.h"
#include <stdio.h>
#include <ctype.h>
-#include "alloc.h"
#include "prototypes.h"
#include "defines.h"
#include <pwd.h>
#include "getdef.h"
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strdup/xstrdup.h"
#ifndef USE_PAM
--- /dev/null
+// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
+// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
+// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
+// SPDX-FileCopyrightText: 2008 , Nicolas François
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include <config.h>
+
+#include "string/strdup/xstrdup.h"
+
+
+extern inline char *xstrdup(const char *str);
--- /dev/null
+// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
+// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
+// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
+// SPDX-FileCopyrightText: 2008 , Nicolas François
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRDUP_H_
+#define SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRDUP_H_
+
+
+#include <config.h>
+
+#include <string.h>
+
+#include "alloc.h"
+#include "attr.h"
+
+
+ATTR_MALLOC(free)
+inline char *xstrdup(const char *str);
+
+
+inline char *
+xstrdup(const char *str)
+{
+ return strcpy(XMALLOC(strlen(str) + 1, char), str);
+}
+
+
+#endif // include guard
#include "sizeof.h"
#include "string/strcpy/strncpy.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
#include "string/strdup/xstrndup.h"
#ident "$Id$"
#endif /* ACCT_TOOLS_SETUID */
#include <pwd.h>
-#include "alloc.h"
#include "atoi/str2i.h"
#include "defines.h"
#include "memzero.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
#include "string/strftime.h"
#include "time/day_to_str.h"
/*@-exitarg@*/
#include <sys/types.h>
#include <getopt.h>
-#include "alloc.h"
#include "defines.h"
#include "getdef.h"
#include "nscd.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
/*
#include <stdio.h>
#include <sys/types.h>
-#include "alloc.h"
#include "defines.h"
#include "getdef.h"
#include "nscd.h"
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
#ifndef SHELLS_FILE
#define SHELLS_FILE "/etc/shells"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
/*
#include "sgroupio.h"
#endif
#include "shadowlog.h"
+#include "string/strdup/xstrdup.h"
+
/* Exit Status Values */
/*@-exitarg@*/
#include "shadowlog.h"
#include "string/sprintf/stpeprintf.h"
#include "string/strcpy/stpecpy.h"
+#include "string/strdup/xstrdup.h"
/*
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
#include "string/strftime.h"
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
+#include "string/strdup/xstrdup.h"
/*
#include "chkname.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
+#include "string/strdup/xstrdup.h"
/*
#include <sys/types.h>
#include <time.h>
-#include "alloc.h"
#include "agetpass.h"
#include "atoi/str2i.h"
#include "defines.h"
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
#include "time/day_to_str.h"
-
/*
* exit status values
*/
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcpy/strtcpy.h"
+#include "string/strdup/xstrdup.h"
/*
#include <sys/types.h>
#include "agetpass.h"
-#include "alloc.h"
#include "attr.h"
#include "defines.h"
#include "getdef.h"
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
+#include "string/strdup/xstrdup.h"
/*
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strdup/xstrdup.h"
#ifndef SKEL_DIR
#include <sys/types.h>
#include <unistd.h>
-#include "alloc.h"
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
#include "pam_defs.h"
#endif /* ENABLE_SUBIDS */
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strdup/xstrdup.h"
/*
#endif
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strdup/xstrdup.h"
#include "time/day_to_str.h"