Sunday, April 07, 2024

Re: 7.5 /var/log/messages - vfprintf %s NULL in "%.*s"

On 2024-04-06, Страхиња Радић <contact@strahinja.org> wrote:
> Дана 24/04/06 06:04PM, Stuart Henderson написа:
>> The fact that these all started hitting this with the same printf string
>> (including tmux, which is in base) makes me wonder if it's coming from a
>> library, the most likely being libcurses which was updated between 7.4
>> and 7.5 (which all of those use).
>>
>> Try to ascertain what's going on when that message is logged. ktrace
>> might give some clues.
>
> Of course, the package containing the code passing NULL to *printf should be
> identified first, and the bug report should be sent to that package. It is
> entirely possible that it is libcurses or another library. In the case of
> dunst, it was dunst.

libcurses and tmux are not packages, they are in the base OS.

> Passing NULL to *printf is Undefined Behavior in C, and there is a
> StackOverflow answer detailing the reasons at [1].
>
> [1]: https://stackoverflow.com/a/11589500

Yes. It's very common though, especially when constructing strings for
debug logging. I see this a lot with software in the GNOME ecosystem
using sprintf for this.

That's interesting about the compiler optimisation for printf->puts,
though I think it won't be used in many cases where the pointer nay be
null so many uses of this won't trigger crashes for that reason.


--
Please keep replies on the mailing list.

No comments:

Post a Comment