author | Elliott Hughes <enh@google.com> | |
Thu, 18 Dec 2014 21:36:25 +0000 (13:36 -0800) | ||
committer | Elliott Hughes <enh@google.com> | |
Thu, 18 Dec 2014 23:01:10 +0000 (15:01 -0800) | ||
commit | 7874f1d7182d80eb72c699eaa9ab8cc4cfec95ab | |
tree | 4348cc097c742280038ff78b454d6cd513cd619e | tree | snapshot (tar.xz tar.gz zip) |
parent | 9dd5ab46194a3ef7992b0c08d18f2e30551f9331 | commit | diff |
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
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 | diff | blob | history | |
libc/private/bionic_tls.h | diff | blob | history |