* lib/argz.c (argz_next): Use strnul.
* lib/cpu-supports.c (hwcap_allowed): Likewise.
* lib/file-has-acl.c (aclinfo_has_xattr): Likewise.
* lib/inet_ntop.c (inet_ntop6): Likewise.
* lib/link.c (link): Likewise.
* lib/localename-unsafe.c (enum_locales_fn): Likewise.
* lib/mbspcasecmp.c (mbspcasecmp): Likewise.
* lib/opendir.c (opendir): Likewise.
* lib/parse-duration.c (parse_year_month_day, parse_hour_minute_second,
trim): Likewise.
* lib/setlocale.c (setlocale_unixlike): Likewise.
* lib/strftime.c (__strftime_internal): Likewise.
* lib/striconv.c (str_cd_iconv): Likewise.
* lib/strncat.c (strncat): Likewise.
* lib/term-style-control.c (log_signal_handler_called,
tcsetattr_failed): Likewise.
* lib/time_rz.c (save_abbr): Likewise.
* lib/vc-mtime.c (git_mtime, max_vc_mtime): Likewise.
* tests/test-savedir.c (test_savedir_sort_none, test_savedir_sort_name):
Likewise.
* modules/argz (Depends-on): Add strnul.
* modules/cpu-supports (Depends-on): Likewise.
* modules/file-has-acl (Depends-on): Likewise.
* modules/inet_ntop (Depends-on): Likewise.
* modules/link (Depends-on): Likewise.
* modules/localename-unsafe (Depends-on): Likewise.
* modules/localename-unsafe-limited (Depends-on): Likewise.
* modules/mbspcasecmp (Depends-on): Likewise.
* modules/opendir (Depends-on): Likewise.
* modules/parse-duration (Depends-on): Likewise.
* modules/setlocale (Depends-on): Likewise.
* modules/nstrftime (Depends-on): Likewise.
* modules/nstrftime-limited (Depends-on): Likewise.
* modules/c-nstrftime (Depends-on): Likewise.
* modules/fprintftime (Depends-on): Likewise.
* modules/striconv (Depends-on): Likewise.
* modules/strncat (Depends-on): Likewise.
* modules/term-style-control (Depends-on): Likewise.
* modules/time_rz (Depends-on): Likewise.
* modules/vc-mtime (Depends-on): Likewise.
* modules/savedir-tests (Depends-on): Likewise.
Copyright-paperwork-exempt: Yes
+2026-02-23 Alejandro Colomar <alx@kernel.org>
+
+ Use strnul in a few places.
+ * lib/argz.c (argz_next): Use strnul.
+ * lib/cpu-supports.c (hwcap_allowed): Likewise.
+ * lib/file-has-acl.c (aclinfo_has_xattr): Likewise.
+ * lib/inet_ntop.c (inet_ntop6): Likewise.
+ * lib/link.c (link): Likewise.
+ * lib/localename-unsafe.c (enum_locales_fn): Likewise.
+ * lib/mbspcasecmp.c (mbspcasecmp): Likewise.
+ * lib/opendir.c (opendir): Likewise.
+ * lib/parse-duration.c (parse_year_month_day, parse_hour_minute_second,
+ trim): Likewise.
+ * lib/setlocale.c (setlocale_unixlike): Likewise.
+ * lib/strftime.c (__strftime_internal): Likewise.
+ * lib/striconv.c (str_cd_iconv): Likewise.
+ * lib/strncat.c (strncat): Likewise.
+ * lib/term-style-control.c (log_signal_handler_called,
+ tcsetattr_failed): Likewise.
+ * lib/time_rz.c (save_abbr): Likewise.
+ * lib/vc-mtime.c (git_mtime, max_vc_mtime): Likewise.
+ * tests/test-savedir.c (test_savedir_sort_none, test_savedir_sort_name):
+ Likewise.
+ * modules/argz (Depends-on): Add strnul.
+ * modules/cpu-supports (Depends-on): Likewise.
+ * modules/file-has-acl (Depends-on): Likewise.
+ * modules/inet_ntop (Depends-on): Likewise.
+ * modules/link (Depends-on): Likewise.
+ * modules/localename-unsafe (Depends-on): Likewise.
+ * modules/localename-unsafe-limited (Depends-on): Likewise.
+ * modules/mbspcasecmp (Depends-on): Likewise.
+ * modules/opendir (Depends-on): Likewise.
+ * modules/parse-duration (Depends-on): Likewise.
+ * modules/setlocale (Depends-on): Likewise.
+ * modules/nstrftime (Depends-on): Likewise.
+ * modules/nstrftime-limited (Depends-on): Likewise.
+ * modules/c-nstrftime (Depends-on): Likewise.
+ * modules/fprintftime (Depends-on): Likewise.
+ * modules/striconv (Depends-on): Likewise.
+ * modules/strncat (Depends-on): Likewise.
+ * modules/term-style-control (Depends-on): Likewise.
+ * modules/time_rz (Depends-on): Likewise.
+ * modules/vc-mtime (Depends-on): Likewise.
+ * modules/savedir-tests (Depends-on): Likewise.
+
2026-02-23 Bruno Haible <bruno@clisp.org>
strnul: Respect GNULIB_NAMESPACE.
if (entry)
{
if (entry < argz + argz_len)
- entry = strchr (entry, '\0') + 1;
+ entry = strnul (entry) + 1;
return entry >= argz + argz_len ? NULL : (char *) entry;
}
char const *sentinel = strchr (hwcaps, ':');
if (! sentinel)
- sentinel = hwcaps + strlen (hwcaps);
+ sentinel = strnul (hwcaps);
char const *cap = hwcaps;
while ((cap = strstr (cap, glibc_hwcap)) && cap < sentinel)
{ /* Check it's not a partial match. */
if (0 < ai->size)
{
char const *blim = ai->buf + ai->size;
- for (char const *b = ai->buf; b < blim; b += strlen (b) + 1)
+ for (char const *b = ai->buf; b < blim; b = strnul (b) + 1)
for (char const *a = xattr; *a == *b; a++, b++)
if (!*a)
return true;
{
if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
return (NULL);
- tp += strlen (tp);
+ tp = strnul (tp);
break;
}
{
return -1;
{
struct stat st;
- char *p = strchr (dir, '\0');
+ char *p = strnul (dir);
while (dir < p && (*--p != '/' && *p != '\\'));
*p = '\0';
if (p != dir && stat (dir, &st) != 0 && errno != EOVERFLOW)
{
strcat (locval, "_");
if (GetLocaleInfo (try_lcid, LOCALE_SENGCOUNTRY,
- locval + strlen (locval), LOCALE_NAME_MAX_LENGTH))
+ strnul (locval), LOCALE_NAME_MAX_LENGTH))
{
size_t locval_len = strlen (locval);
mbsncasecmp (string, prefix, mbslen (prefix))
just with small optimizations. */
if (string == prefix)
- return (char *) (string + strlen (string));
+ return (char *) strnul (string);
const char *iter1 = string;
const char *iter2 = prefix;
{
char *p;
- p = dir_name_mask + strlen (dir_name_mask);
+ p = strnul (dir_name_mask);
if (p > dir_name_mask && !ISSLASH (p[-1]))
*p++ = '\\';
*p++ = '*';
res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH);
pz++; /* over the second '-' */
- ps = pz + strlen (pz);
+ ps = strnul (pz);
return parse_scaled_value (res, &pz, ps, SEC_PER_DAY);
}
res = parse_scaled_value (res, &pz, ps, SEC_PER_MIN);
pz++;
- ps = pz + strlen (pz);
+ ps = strnul (pz);
return parse_scaled_value (res, &pz, ps, 1);
}
/* trim trailing white space */
{
- char * pe = pz + strlen (pz);
+ char * pe = strnul (pz);
while ((pe > pz) && isspace ((unsigned char)pe[-1]))
pe--;
*pe = NUL;
const char *territory_start = underscore + 1;
const char *territory_end = strchr (territory_start, '@');
if (territory_end == NULL)
- territory_end = territory_start + strlen (territory_start);
+ territory_end = strnul (territory_start);
char ll_buf[64];
memcpy (ll_buf, llCC_buf, underscore - llCC_buf);
mbstate_t mbstate = mbstate_zero;
if (! format_end)
- format_end = f + strlen (f) + 1;
+ format_end = strnul (f) + 1;
size_t fsize = format_end - f;
size_t len = 0;
for (;;)
{
- /* Here inptr + inbytes_remaining = src + strlen (src),
+ /* Here inptr + inbytes_remaining = strnul (src),
outptr + outbytes_remaining = result + result_size - 1. */
size_t res = iconv (cd,
(ICONV_CONST char **) &inptr, &inbytes_remaining,
char *
strncat (char *dest, const char *src, size_t n)
{
- char *destptr = dest + strlen (dest);
+ char *destptr = strnul (dest);
for (; n > 0 && (*destptr = *src) != '\0'; src++, destptr++, n--)
;
{
char message[100];
strcpy (message, "Signal handler for signal ");
- simple_signal_string (message + strlen (message), sig);
+ simple_signal_string (strnul (message), sig);
strcat (message, " called.\n");
log_message (message);
}
int errnum = errno;
strcpy (message, caller);
strcat (message, ": tcsetattr(fd=");
- sprintf_integer (message + strlen (message), active_fd);
+ sprintf_integer (strnul (message), active_fd);
strcat (message, ") failed, errno=");
- simple_errno_string (message + strlen (message), errnum);
+ simple_errno_string (strnul (message), errnum);
strcat (message, "\n");
}
break;
}
- zone_copy += strlen (zone_copy) + 1;
+ zone_copy = strnul (zone_copy) + 1;
if (!*zone_copy && tz->next)
{
tz = tz->next;
char *endptr;
unsigned long git_log_time;
if (xstrtoul (line, &endptr, 10, &git_log_time, NULL) == LONGINT_OK
- && endptr == line + strlen (line))
+ && endptr == strnul (line))
{
mtime->tv_sec = git_log_time;
mtime->tv_nsec = 0;
char *endptr;
unsigned long git_log_time;
if (!(xstrtoul (line, &endptr, 10, &git_log_time, NULL) == LONGINT_OK
- && endptr == line + strlen (line)))
+ && endptr == strnul (line)))
{
fprintf (stderr, "vc-mtime: git log output not as expected\n");
goto git_log_fail1;
stpcpy [test -n "$ARGZ_H"]
strndup [test -n "$ARGZ_H"]
strnlen [test -n "$ARGZ_H"]
+strnul [test -n "$ARGZ_H"]
strstr [test -n "$ARGZ_H"]
configure.ac:
locale-h
bool
stdckdint-h
+strnul
time_rz
configure.ac:
bool
c99
stringeq
+strnul
configure.ac:
AC_REQUIRE([AC_C_INLINE])
limits-h
stdint-h
stringeq
+strnul
malloc-posix
ssize_t
stat
stdio-h
sys_types-h
nstrftime
+strnul
time_rz
configure.ac:
sys_socket-h [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1]
errno-h [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1]
netinet_in-h [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1]
+strnul [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1]
configure.ac:
gl_FUNC_INET_NTOP
free-posix [test $HAVE_LINK = 0 || test $REPLACE_LINK = 1]
stat [test $HAVE_LINK = 0 || test $REPLACE_LINK = 1]
strdup-posix [test $HAVE_LINK = 0 || test $REPLACE_LINK = 1]
+strnul [test $HAVE_LINK = 0 || test $REPLACE_LINK = 1]
sys_stat-h [test $HAVE_LINK = 0 || test $REPLACE_LINK = 1]
configure.ac:
strdup
stringeq
strncpy
+strnul
windows-mutex
getlocalename_l-unsafe
setlocale-null-unlocked
locale-h
strdup
strncpy
+strnul
windows-mutex
getlocalename_l-unsafe-limited
setlocale-null-unlocked
c32tolower
mbuiterf
string-h
+strnul
configure.ac:
gl_STRING_MODULE_INDICATOR([mbspcasecmp])
bool
stdckdint-h
stdint-h
+strnul
time_rz
configure.ac:
localename-unsafe-limited [case "$host_os" in darwin*) false ;; *) true ;; esac]
bool
stdckdint-h
+strnul
time_rz
configure.ac:
unistd-h [test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1]
closedir [test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1]
dirfd [test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1]
+strnul [test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1]
configure.ac:
gl_FUNC_OPENDIR
Depends-on:
intprops
+strnul
configure.ac:
creat
close
mkdir
+strnul
configure.ac:
setlocale-fixes [test $NEED_SETLOCALE_IMPROVED = 1]
localename [test $NEED_SETLOCALE_IMPROVED = 1]
localename-environ [test $NEED_SETLOCALE_IMPROVED = 1]
+strnul [test $NEED_SETLOCALE_IMPROVED = 1]
setlocale-null [test $NEED_SETLOCALE_MTSAFE = 1]
configure.ac:
iconv_open
free-posix
strdup
+strnul
c-strcasecmp
configure.ac:
Depends-on:
string-h
+strnul
configure.ac:
gl_FUNC_STRNCAT
full-write
fstat
same-inode
+strnul
xalloc-die
configure.ac:
setenv [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]
bool [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]
stringeq [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]
+strnul [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]
time_r [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]
timegm [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]
tzset [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1]
bool
spawn-pipe
stringeq
+strnul
wait-process
execute
safe-read
memset (seen, 0, sizeof seen);
/* Scan through the file names. */
- for (char *namep = name_space; *namep != '\0'; namep += strlen (namep) + 1)
+ for (char *namep = name_space; *namep != '\0'; namep = strnul (namep) + 1)
{
int index = *namep - 'a';
ASSERT (strlen (namep) == 1);
/* Check that files "a" to "z" appear in order. */
for (char *namep = name_space; *namep != '\0';
- namep += strlen (namep) + 1, i += 1)
+ namep = strnul (namep) + 1, i += 1)
{
ASSERT (strlen (namep) == 1);
ASSERT (*namep - 'a' == i);