login: fix ut_line comparison logic

Collin Funk collin.funk1@gmail.com
Thu Aug 7 23:56:41 GMT 2025


Sam James <sam@gentoo.org> writes:

> DJ Delorie <dj@redhat.com> writes:
>
>> ut_line[] is not a string, it's a fixed-width character field,
>> and may not be NUL terminated.  Thus, the use of strcmp is incorrect.
>> strncmp is more appropriate as it stops at the field size.
>
> Yes. While at least my copy of man-pages talks about "strings", a copy
> of C23 makes clear that the array is only "possibly null-terminated" for
> strncmp.

Yep, they talk about strings for me as well. But the important part:

    String fields are terminated by a null byte ('\0') if they are
    shorter than the size of the field.

That is man-pages 6.9.1, so ours could be different.

Collin


More information about the Libc-alpha mailing list