]> git.ipfire.org Git - thirdparty/glibc.git/commit
Avoid use of strlen in getlogin_r (bug 22447).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 22 Nov 2017 18:44:23 +0000 (18:44 +0000)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 22 Oct 2018 11:58:39 +0000 (13:58 +0200)
commit27611fd05b444042de4a718c2f21e9efae755825
tree8bd26a12378ff18ecdcaeca026ba8e053460c454
parent48bef587bfd4b6c11ae227075eb1492b10a395a8
Avoid use of strlen in getlogin_r (bug 22447).

Building glibc with current mainline GCC fails, among other reasons,
because of an error for use of strlen on the nonstring ut_user field.
This patch changes the problem code in getlogin_r to use __strnlen
instead.  It also needs to set the trailing NUL byte of the result
explicitly, because of the case where ut_user does not have such a
trailing NUL byte (but the result should always have one).

Tested for x86_64.  Also tested that, in conjunction with
<https://sourceware.org/ml/libc-alpha/2017-11/msg00797.html>, it fixes
the build for arm with mainline GCC.

[BZ #22447]
* sysdeps/unix/getlogin_r.c (__getlogin_r): Use __strnlen not
strlen to compute length of ut_user and set trailing NUL byte of
result explicitly.

(cherry picked from commit 4bae615022cb5a5da79ccda83cc6c9ba9f2d479c)
ChangeLog
NEWS
sysdeps/unix/getlogin_r.c