[Nut-upsdev] common/common.c snprintf warning

Jim Klimov jimklimov+nut at gmail.com
Mon Mar 31 15:18:28 BST 2025


The problem is, as far as NUT code is concerned, we are using tolower(),
isalpha() etc. which may well be real functions in some libraries and
macros with bit-shift magic or arrays on others...
This is hard to catch without actually running builds on dozens of
platforms :)

Jim


On Mon, Mar 31, 2025 at 4:13 PM Greg Troxel <gdt at lexort.com> wrote:

> Jim Klimov <jimklimov+nut at gmail.com> writes:
>
> > It seems bumping all those buffers to [NUT_PATH_MAX+1]` (for the NUL
> ending
> > char) helps, and seems a reasonable thing to do safely.
>
> Sure, if that helps that really seems sensible.
>
> > the char subscripts only with CLANG (13), on my dormant NetBSD 9.2 VM.
>
> NetBSD is louder about it, but ctype(3) is really hard to use correctly
> and risks undefined behavior.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/nut-upsdev/attachments/20250331/e2d1e341/attachment.htm>


More information about the Nut-upsdev mailing list