Merge pull request #350 from TheModMaker/fixIosSim

Allow getpwuid_r to return missing entry.
This commit is contained in:
Sergiu Deitsch 2019-10-31 23:00:31 +01:00 committed by GitHub
commit 242130d305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -31,6 +31,7 @@ Fumitoshi Ukai <ukai@google.com>
Guillaume Dumont <dumont.guillaume@gmail.com> Guillaume Dumont <dumont.guillaume@gmail.com>
Håkan L. S. Younes <hyounes@google.com> Håkan L. S. Younes <hyounes@google.com>
Ivan Penkov <ivanpe@google.com> Ivan Penkov <ivanpe@google.com>
Jacob Trimble <modmaker@google.com>
Jim Ray <jimray@google.com> Jim Ray <jimray@google.com>
Michael Tanner <michael@tannertaxpro.com> Michael Tanner <michael@tannertaxpro.com>
MiniLight <MiniLightAR@Gmail.com> MiniLight <MiniLightAR@Gmail.com>

View File

@ -311,7 +311,7 @@ static void MyUserNameInitializer() {
char buffer[1024] = {'\0'}; char buffer[1024] = {'\0'};
uid_t uid = geteuid(); uid_t uid = geteuid();
int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &result); int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &result);
if (pwuid_res == 0) { if (pwuid_res == 0 && result) {
g_my_user_name = pwd.pw_name; g_my_user_name = pwd.pw_name;
} else { } else {
snprintf(buffer, sizeof(buffer), "uid%d", uid); snprintf(buffer, sizeof(buffer), "uid%d", uid);