Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ libshadow_la_SOURCES = \
lockpw.c \
loginprompt.c \
mail.c \
memory/memcpy/strncat.c \
memory/memcpy/strncat.h \
memory/memcpy/strncpy.c \
memory/memcpy/strncpy.h \
memory/memdup/memdup.c \
memory/memdup/memdup.h \
memory/memdup/strndup.c \
memory/memdup/strndup.h \
memory/memset/memzero.c \
memory/memset/memzero.h \
memory/strncmp/strneq.c \
memory/strncmp/strneq.h \
motd.c \
myname.c \
nss.c \
Expand Down Expand Up @@ -197,8 +209,6 @@ libshadow_la_SOURCES = \
string/ctype/isascii.h \
string/ctype/toascii.c \
string/ctype/toascii.h \
string/memset/memzero.c \
string/memset/memzero.h \
string/sprintf/aprintf.c \
string/sprintf/aprintf.h \
string/sprintf/seprintf.c \
Expand All @@ -217,24 +227,14 @@ libshadow_la_SOURCES = \
string/strcmp/strcaseprefix.h \
string/strcmp/streq.c \
string/strcmp/streq.h \
string/strcmp/strneq.c \
string/strcmp/strneq.h \
string/strcmp/strprefix.c \
string/strcmp/strprefix.h \
string/strcpy/stpecpy.c \
string/strcpy/stpecpy.h \
string/strcpy/strncat.c \
string/strcpy/strncat.h \
string/strcpy/strncpy.c \
string/strcpy/strncpy.h \
string/strcpy/strtcpy.c \
string/strcpy/strtcpy.h \
string/strdup/memdup.c \
string/strdup/memdup.h \
string/strdup/strdup.c \
string/strdup/strdup.h \
string/strdup/strndup.c \
string/strdup/strndup.h \
string/strftime.c \
string/strftime.h \
string/strspn/stpspn.c \
Expand All @@ -255,6 +255,8 @@ libshadow_la_SOURCES = \
string/strtok/strsep2arr.h \
string/strtok/strsep2ls.c \
string/strtok/strsep2ls.h \
string/strzero/strzero.c \
string/strzero/strzero.h \
strtoday.c \
sub.c \
subordinateio.h \
Expand Down
2 changes: 1 addition & 1 deletion lib/commonio.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
#include "defines.h"
#include "fs/mkstemp/fmkomstemp.h"
#include "io/fprintf.h"
#include "memory/memset/memzero.h"
#include "nscd.h"
#ifdef WITH_TCB
#include <tcb.h>
#endif /* WITH_TCB */
#include "prototypes.h"
#include "shadowlog.h"
#include "sssd.h"
#include "string/memset/memzero.h"
#include "string/sprintf/aprintf.h"
#include "string/sprintf/stprintf.h"
#include "string/strcmp/streq.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "faillog.h"
#include "failure.h"
#include "io/syslog.h"
#include "memory/memset/memzero.h"
#include "prototypes.h"
#include "string/memset/memzero.h"
#include "string/strftime.h"
#include "string/strcpy/strtcpy.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/groupmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "prototypes.h"
#include "defines.h"
#include "groupio.h"
#include "string/memset/memzero.h"
#include "string/strzero/strzero.h"


/*@null@*/ /*@only@*/struct group *__gr_dup (const struct group *grent)
Expand Down
2 changes: 1 addition & 1 deletion lib/limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "atoi/a2i.h"
#include "io/fgets/fgets.h"
#include "string/memset/memzero.h"
#include "memory/memset/memzero.h"
#include "string/strcmp/streq.h"
#include "string/strcmp/strprefix.h"
#include "string/strspn/stpspn.h"
Expand Down
4 changes: 2 additions & 2 deletions lib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "attr.h"
#include "defines.h"
#include "io/syslog.h"
#include "memory/memcpy/strncpy.h"
#include "memory/memset/memzero.h"
#include "prototypes.h"
#include "string/memset/memzero.h"
#include "string/strcpy/strncpy.h"
#include "string/strcpy/strtcpy.h"


Expand Down
2 changes: 1 addition & 1 deletion lib/loginprompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "defines.h"
#include "getdef.h"
#include "io/fgets/fgets.h"
#include "memory/memset/memzero.h"
#include "prototypes.h"
#include "string/memset/memzero.h"
#include "string/strcpy/strtcpy.h"
#include "string/strspn/stpspn.h"
#include "string/strtok/stpsep.h"
Expand Down
1 change: 1 addition & 0 deletions lib/memory/README
7 changes: 7 additions & 0 deletions lib/memory/memcpy/strncat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include "memory/memcpy/strncat.h"
8 changes: 4 additions & 4 deletions lib/string/strcpy/strncat.h → lib/memory/memcpy/strncat.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCAT_H_
#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCAT_H_
#ifndef SHADOW_INCLUDE_LIB_MEMORY_MEMCPY_STRNCAT_H_
#define SHADOW_INCLUDE_LIB_MEMORY_MEMCPY_STRNCAT_H_


#include "config.h"

#include <string.h>
#include <memory.h>

#include "sizeof.h"

Expand Down
7 changes: 7 additions & 0 deletions lib/memory/memcpy/strncpy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include "memory/memcpy/strncpy.h"
8 changes: 4 additions & 4 deletions lib/string/strcpy/strncpy.h → lib/memory/memcpy/strncpy.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCPY_H_
#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCPY_H_
#ifndef SHADOW_INCLUDE_LIB_MEMORY_MEMCPY_STRNCPY_H_
#define SHADOW_INCLUDE_LIB_MEMORY_MEMCPY_STRNCPY_H_


#include "config.h"

#include <string.h>
#include <memory.h>

#include "sizeof.h"

Expand Down
7 changes: 7 additions & 0 deletions lib/memory/memdup/memdup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2025-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include "memory/memdup/memdup.h"
6 changes: 3 additions & 3 deletions lib/string/strdup/memdup.h → lib/memory/memdup/memdup.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2025-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_MEMDUP_H_
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_MEMDUP_H_
#ifndef SHADOW_INCLUDE_LIB_MEMORY_MEMDUP_MEMDUP_H_
#define SHADOW_INCLUDE_LIB_MEMORY_MEMDUP_MEMDUP_H_


#include "config.h"
Expand Down
7 changes: 7 additions & 0 deletions lib/memory/memdup/strndup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include "memory/memdup/strndup.h"
8 changes: 4 additions & 4 deletions lib/string/strdup/strndup.h → lib/memory/memdup/strndup.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_STRNDUP_H_
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_STRNDUP_H_
#ifndef SHADOW_INCLUDE_LIB_MEMORY_MEMDUP_STRNDUP_H_
#define SHADOW_INCLUDE_LIB_MEMORY_MEMDUP_STRNDUP_H_


#include "config.h"

#include <string.h>
#include <memory.h>

#include "sizeof.h"
#include "exit_if_null.h"
Expand Down
5 changes: 2 additions & 3 deletions lib/string/memset/memzero.c → lib/memory/memset/memzero.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2023-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include <stddef.h>

#include "string/memset/memzero.h"
#include "memory/memset/memzero.h"


extern inline void *memzero(void *ptr, size_t size);
extern inline char *strzero(char *s);
17 changes: 4 additions & 13 deletions lib/string/memset/memzero.h → lib/memory/memset/memzero.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-FileCopyrightText: 2022-2023, Christian Göttsche <cgzones@googlemail.com>
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2023-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_STRING_MEMSET_MEMZERO_H_
#define SHADOW_INCLUDE_LIB_STRING_MEMSET_MEMZERO_H_
#ifndef SHADOW_INCLUDE_LIB_MEMORY_MEMSET_MEMZERO_H_
#define SHADOW_INCLUDE_LIB_MEMORY_MEMSET_MEMZERO_H_


#include "config.h"

#include <memory.h>
#include <stddef.h>
#include <string.h>
#include <strings.h>

#include "sizeof.h"
Expand All @@ -21,7 +21,6 @@


inline void *memzero(void *ptr, size_t size);
inline char *strzero(char *s);


// memzero - memory zero (explicit)
Expand All @@ -40,12 +39,4 @@ memzero(void *ptr, size_t size)
}


// strzero - string zero (explicit)
inline char *
strzero(char *s)
{
return memzero(s, strlen(s));
}


#endif // include guard
4 changes: 2 additions & 2 deletions lib/string/strcmp/strneq.c → lib/memory/strncmp/strneq.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2025-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include "string/strcmp/strneq.h"
#include "memory/strncmp/strneq.h"

#include <stdbool.h>
#include <stddef.h>
Expand Down
7 changes: 4 additions & 3 deletions lib/string/strcmp/strneq.h → lib/memory/strncmp/strneq.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2025-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_STRING_STRCMP_STRNEQ_H_
#define SHADOW_INCLUDE_LIB_STRING_STRCMP_STRNEQ_H_
#ifndef SHADOW_INCLUDE_LIB_MEMORY_STRNCMP_STRNEQ_H_
#define SHADOW_INCLUDE_LIB_MEMORY_STRNCMP_STRNEQ_H_


#include "config.h"

#include <memory.h>
#include <stdbool.h>
#include <string.h>

Expand Down
2 changes: 1 addition & 1 deletion lib/obscure.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "defines.h"
#include "getdef.h"
#include "string/ctype/toascii.h"
#include "string/memset/memzero.h"
#include "string/sprintf/aprintf.h"
#include "string/strcmp/streq.h"
#include "string/strdup/strdup.h"
#include "string/strzero/strzero.h"


/*
Expand Down
2 changes: 1 addition & 1 deletion lib/pam_pass_non_interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "attr.h"
#include "prototypes.h"
#include "shadowlog.h"
#include "string/memset/memzero.h"
#include "string/strzero/strzero.h"

#undef NDEBUG
#include <assert.h>
Expand Down
1 change: 0 additions & 1 deletion lib/pwauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "prototypes.h"
#include "pwauth.h"
#include "getdef.h"
#include "string/memset/memzero.h"
#include "string/sprintf/stprintf.h"
#include "string/strcmp/streq.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/pwmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "defines.h"
#include "prototypes.h"
#include "pwio.h"
#include "string/memset/memzero.h"
#include "string/strzero/strzero.h"


/*@null@*/ /*@only@*/struct passwd *__pw_dup (const struct passwd *pwent)
Expand Down
2 changes: 1 addition & 1 deletion lib/sgroupio.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "shadow/gshadow/putsgent.h"
#include "shadow/gshadow/sgetsgent.h"
#include "shadow/gshadow/sgrp.h"
#include "string/memset/memzero.h"
#include "string/strzero/strzero.h"


/*@null@*/ /*@only@*/struct sgrp *__sgr_dup (const struct sgrp *sgent)
Expand Down
2 changes: 1 addition & 1 deletion lib/shadowmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "alloc/calloc.h"
#include "shadowio.h"
#include "string/memset/memzero.h"
#include "string/strzero/strzero.h"


/*@null@*/ /*@only@*/struct spwd *__spw_dup (const struct spwd *spent)
Expand Down
Loading
Loading