From: "Ángel González" <ingenit@zoho.com>
To: Joshua Rogers <megamansec@gmail.com>
Cc: util-linux@vger.kernel.org
Subject: Re: off-by-one issues in login-utils
Date: Sun, 23 Nov 2014 20:52:09 +0100 [thread overview]
Message-ID: <54723AE9.9030905@zoho.com> (raw)
In-Reply-To: <54703C81.7000902@gmail.com>
On 22/11/14 08:34, Joshua Rogers wrote:
> Hi,
>
> I've noticed a few off-by-one issues in login-utils..
>
> login.c:963: strncpy(ut.ut_user, username, sizeof(ut.ut_user));
> It should be sizeof(ut.ut_user) - 1.
> Or, something like
> ut.ut_user[sizeof(ut.ut_user) -1] = '\0';
>
>
> And on line 275:
>
> memset(&ut, 0, sizeof(ut));
>
> strncpy(ut.ut_user, username ? username : "(unknown)",
> sizeof(ut.ut_user));
>
> I can't see anywhere that adds the final NUL-byte to ut.ut_user.
> If I've missed something though, feel free to ignore this.
>
> Thanks,
It's not needed. The reader of utmp(5) shall read up to
sizeof(ut.ut_user) bytes.
From utmp(5):
> String fields are terminated by a null byte ('\0') if they are
> shorter than the size of the field.
Thus it is allowed to have non-NUL-terminated fields on the file.
prev parent reply other threads:[~2014-11-23 20:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-22 7:34 off-by-one issues in login-utils Joshua Rogers
2014-11-23 19:52 ` Ángel González [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54723AE9.9030905@zoho.com \
--to=ingenit@zoho.com \
--cc=megamansec@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.