Package: libc6
Version: 2.41-12
Severity: normal
Tags: upstream
Control: found -1 2.36-9+deb12u13
Control: found -1 2.43-7
Control: forwarded -1 https://sourceware.org/bugzilla/show_bug.cgi?id=22944

Dear Maintainer,

-- >8 --
#include <err.h>
#include <fts.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

int main(int, char * const * argv) {
        errno = 0;
        FTS * stream = fts_open(argv, FTS_PHYSICAL, nullptr);
        for(FTSENT * ent; (ent = fts_read(stream));) {
                printf("%zu: %s\n", strlen(ent->fts_path), ent->fts_info == 
FTS_NS ? "FTS_NS" :
                ent->fts_info == FTS_D ? "FTS_D" :
                ent->fts_info == FTS_DNR ? "FTS_DNR" :
                ent->fts_info == FTS_DP ? "FTS_DP" :
                ent->fts_info == FTS_F ? "FTS_F" :
                ent->fts_info == FTS_SL ? "FTS_SL" :
                ent->fts_info == FTS_SLNONE ? "FTS_SLNONE" :
                ent->fts_info == FTS_DEFAULT ? "FTS_DEFAULT" :
                ent->fts_info == FTS_ERR ? "FTS_ERR" :
                ent->fts_info == FTS_DC ? "FTS_DC" :
                ent->fts_info == FTS_DOT ? "FTS_DOT" :
                ent->fts_info == FTS_NSOK ? "FTS_NSOK" :
                "idk");
        }
        err(0, nullptr);
}
-- >8 --
when run as
  mkdir -p $(yes a/ | head -n $((32 * 1024)) | tr -d '\n') && cc ftstest.c && 
./a.out a
tails out with
  36615: FTS_D
  36617: FTS_D
  36619: FTS_D
  36621: FTS_D
  a.out: File name too long
(with s/a/qq/ it's after 36617). The correct tail ends like
(captured with musl and void-linux/musl-fts 1.2.7):
  5: FTS_DP
  3: FTS_DP
  1: FTS_DP
  a.out: No error information

Upstream commit 99303f387179332d64e5ee34a6b58e82a523bae5
(io: Use gnulib fts implementation (BZ 22944, BZ 20331)),
included in glibc 2.44, fixes this:
  65529: FTS_D
  65531: FTS_D
  65533: FTS_D
  65535: FTS_D
  65535: FTS_DP
  65533: FTS_DP
  65531: FTS_DP
  65529: FTS_DP
  65527: FTS_DP
  ...
  13: FTS_DP
  11: FTS_DP
  9: FTS_DP
  7: FTS_DP
  5: FTS_DP
  3: FTS_DP
  1: FTS_DP
  a: Success

This bug appears equivalent to
  https://sourceware.org/bugzilla/show_bug.cgi?id=22944

However, glibc 2.44 and trunk (46d325b68c1e49ad87b5e99a1ec9df5406350e31)
have a different bug when given absolute filenames in this case.

Best,

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: x32 (x86_64)
Foreign Architectures: amd64, i386

Kernel: Linux 6.7.7-amd64 (SMP w/2 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libc6 depends on:
ii  libgcc-s1  14.2.0-14

Versions of packages libc6 recommends:
ii  libidn2-0  2.3.7-2+b1

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]  1.5.89
pn  glibc-doc              <none>
ii  libc-l10n              2.41-12
ii  libnss-nis             3.1-5+b1
ii  libnss-nisplus         1.3-5+b2
ii  locales                2.41-12

-- debconf information excluded

Attachment: signature.asc
Description: PGP signature

Reply via email to