OSDN Git Service

Split the shared group data from the shared passwd data.
authorElliott Hughes <enh@google.com>
Thu, 18 Dec 2014 21:36:25 +0000 (13:36 -0800)
committerElliott Hughes <enh@google.com>
Thu, 18 Dec 2014 23:01:10 +0000 (15:01 -0800)
commit7874f1d7182d80eb72c699eaa9ab8cc4cfec95ab
tree4348cc097c742280038ff78b454d6cd513cd619e
parent9dd5ab46194a3ef7992b0c08d18f2e30551f9331
Split the shared group data from the shared passwd data.

Found by the toybox id(1) which calls both getpwuid(3) and getgrgid(3) before
looking at either result. The use of a shared buffer in this code meant that
even on a single thread, the data for any of the passwd functions would be
clobbered by the data for any of the group functions (or vice versa).

This might seem like an insufficient fix, but POSIX explicitly says (for
getpwnam) that the result "might be overwritten by a subsequent call to
getpwent(), getpwnam(), or getpwuid()" and likewise for other members of
that group, plus equivalent text for the group-related functions.

Change-Id: I2272f47e91f72e043fdaf7c169fa9f6978ff4370
libc/bionic/stubs.cpp
libc/private/bionic_tls.h