Re: porting to Fil-C
Paul Eggert <[email protected]> Sun, 26 Jul 2026 14:17:39 -0700
| Newsgroups | gmane.comp.lib.gnulib.bugs |
|---|---|
| Organization | UCLA Computer Science Department |
| Message-ID | <[email protected]> |
On 2026-07-25 19:40, Bruno Haible wrote: > Paul Eggert wrote: >>> +#if defined __FILC__ >>> + if (lenbuf > INT_MAX) >>> + lenbuf = INT_MAX; >>> +#endif >> >> ... Should Fil-C be listed as >> buggy in doc/posix-functions/snprintf.texi, >> doc/posix-functions/vsnprintf.texi, next to other platforms that >> mishandle the sizes INT_MAX + 1u (Solaris, z/OS) or INT_MAX + 2u >> (FreeBSD, OpenBSD, NetBSD, macOS)? > > Yes. When lenbuf has the value INT_MAX + 1, the vasnprintf call fails; > when it has the value INT_MAX, the vasnprintf call succeeds. I'm a little puzzled, as my question was about snprintf and vsnprintf, not about vasnprintf. However, assuming that you meant snprintf and vasnprintf I installed the attached patch. As the patch mentions I wasn't sure where to put Fil-C (and z/OS) in the Supported Platforms list but I gave it a guess. >> Something like the attacheded untest patch, perhaps, which I stole from >> lib/vasnprintf.c? > > No, none of the three parts would work. Oh, I see now see a mistake in my patch. I thought those were calls to snprintf and vsnprintf, but they are actually calls to a vasnprintf-like function. But I'm still puzzled. I thought vasnprintf was supplied by Gnulib and so does not have the INT_MAX limitation. If so, why limit sizes to INT_MAX when calling vasnprintf? Because of the Fil-C problem you mention (that I assume is actually with snprintf and vsnprintf), should lib/vasnprintf.c's USE_SNPRINTF be 0 if Lib-C is in use? I'm thinking that would work around the Lib-C bug more generally, without the need for INT_MAX #ifdefs in callers.
0001-snprintf-vsnprintf-update-doc.patch
(text/x-patch, 3.1 KB)
From cf2d119406a4c5bbf741a505a397d7f5dae0e216 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Sun, 26 Jul 2026 11:43:06 -0700 Subject: [PATCH] snprintf, vsnprintf: update doc * doc/gnulib-intro.texi (Supported Platforms): Also mention z/OS, Fil-C. Not sure where they should be listed but I gave it a guess. * doc/posix-functions/snprintf.texi (snprintf): * doc/posix-functions/vsnprintf.texi (vsnprintf): Also mention Fil-C bug. --- ChangeLog | 10 ++++++++++ doc/gnulib-intro.texi | 4 ++++ doc/posix-functions/snprintf.texi | 2 +- doc/posix-functions/vsnprintf.texi | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a5d11b2c9..8fb1fccc2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2026-07-26 Paul Eggert <[email protected]> + + snprintf, vsnprintf: update doc + * doc/gnulib-intro.texi (Supported Platforms): + Also mention z/OS, Fil-C. Not sure where they should be listed + but I gave it a guess. + * doc/posix-functions/snprintf.texi (snprintf): + * doc/posix-functions/vsnprintf.texi (vsnprintf): + Also mention Fil-C bug. + 2026-07-25 Bruno Haible <[email protected]> tests: Avoid some runtime errors with Fil-C. diff --git a/doc/gnulib-intro.texi b/doc/gnulib-intro.texi index b7375f2059..8e94c8dfd5 100644 --- a/doc/gnulib-intro.texi +++ b/doc/gnulib-intro.texi @@ -197,6 +197,8 @@ glibc on kFreeBSD is rarely tested. @item @c There is Alpine Linux 3.19, and also musl-gcc on Ubuntu. musl libc on Linux is occasionally tested. +@item +Fil-C on Linux is occasionally tested. @end itemize @item macOS@. In versions 12.5, it's occasionally tested. In version @@ -238,6 +240,8 @@ The versions of Windows that are supported are Windows 10 and newer. @item GNU Hurd 0.9 is rarely tested. @item +z/OS is not tested. +@item Minix 3.3.0 is no longer tested. @item Haiku is no longer tested. diff --git a/doc/posix-functions/snprintf.texi b/doc/posix-functions/snprintf.texi index e05b89ce49..23dd6704fa 100644 --- a/doc/posix-functions/snprintf.texi +++ b/doc/posix-functions/snprintf.texi @@ -140,7 +140,7 @@ Portability problems not fixed by Gnulib: @item This function fails if the buffer size exceeds @code{INT_MAX}, even if the resulting string length would fit in @code{int}: -NetBSD, Solaris, z/OS. +NetBSD, Solaris, z/OS, Fil-C. @item This function fails if the buffer size exceeds @code{INT_MAX + 1u}, even if the resulting string length would fit in @code{int}: diff --git a/doc/posix-functions/vsnprintf.texi b/doc/posix-functions/vsnprintf.texi index 27f3efc5d8..8a6ca05706 100644 --- a/doc/posix-functions/vsnprintf.texi +++ b/doc/posix-functions/vsnprintf.texi @@ -138,7 +138,7 @@ Portability problems not fixed by Gnulib: @item This function fails if the buffer size exceeds @code{INT_MAX}, even if the resulting string length would fit in @code{int}: -NetBSD, Solaris, z/OS. +NetBSD, Solaris, z/OS, Fil-C. @item This function fails if the buffer size exceeds @code{INT_MAX + 1u}, even if the resulting string length would fit in @code{int}: -- 2.53.0