This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Are ut_user and ut_host in struct utmp NUL-terminated?
- From: "Michael Kerrisk (man-pages)" <mtk dot manpages at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, "linux-man at vger dot kernel dot org" <linux-man at vger dot kernel dot org>
- Cc: mtk dot manpages at gmail dot com
- Date: Tue, 21 Aug 2018 10:47:46 +0200
- Subject: Re: Are ut_user and ut_host in struct utmp NUL-terminated?
- References: <11742781-3872-5bbf-55d6-8ce597f21e53@redhat.com>
On 08/13/2018 02:10 PM, Florian Weimer wrote:
> Can ut_user be exactly UT_NAMESIZE bytes long? Or is it necessary to
> set aside a byte with the NUL terminator?
>
> I'm not sure what POSIX says about struct utmpx. It never says “string”
> in the context of ut_user, so I don't think it clarifies this matter.
Each of the char fields in utmp/utmpx can be completely filled with
characters. (I.e., there may not be a terminating null byte.)
As you note, POSIX does not say much here, but perhaps the fact that
the term "string" is not mentioned is a clue.
Thanks,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/