Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88c997d4 authored by Robert Yang's avatar Robert Yang
Browse files

adb: Use a default _SC_GETPW_R_SIZE_MAX size



sysconf(_SC_GETPW_R_SIZE_MAX) may return −1 if there is no hard limit
on the the buffer size. Some libc implementations such as musl don't
define this limit and will return -1.

Use a default buffer size to handle this case.

Change-Id: I997b13a2c2dca00574e049a259135e61c8ed8e03
Signed-off-by: default avatarRobert Yang <decatf@gmail.com>
parent ac305c82
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -293,6 +293,9 @@ std::string adb_get_homedir_path() {
    struct passwd pwent;
    struct passwd* result;
    int pwent_max = sysconf(_SC_GETPW_R_SIZE_MAX);
    if (pwent_max == -1) {
        pwent_max = 16384;
    }
    std::vector<char> buf(pwent_max);
    int rc = getpwuid_r(getuid(), &pwent, buf.data(), buf.size(), &result);
    if (rc == 0 && result) {