镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

reject OEM user and group names with trailing characters - #81

Open
cameronaaron wants to merge 1 commit into
GrapheneOS:17from
cameronaaron:oem-id-from-name-strict
Open

cameronaaron wants to merge 1 commit into
GrapheneOS:17from
cameronaaron:oem-id-from-name-strict

Conversation

@cameronaaron

@cameronaaron cameronaaron commented Oct 27, 2026 •

Copy link
Copy Markdown

Closes GrapheneOS/os-issue-tracker#8027

sscanf(name, "oem_%u", &id) only checks that a number was read, so getpwnam("oem_2900x"), "oem_+2900" and "oem_ 2900" all resolved to uid 2900. This parses the id the same way app_id_from_name does (digits only, whole string consumed) and range-checks it before narrowing to id_t.

Added negative cases to getpwnam_non_exist and getgrnam_non_exist. I haven't run bionic-unit-tests on a device. I compared the new function against the old one on the host for valid and malformed names, and checked that the range comparison doesn't trigger -Wtype-limits on 32-bit targets. The same code is still in AOSP main.

oem_id_from_name used sscanf("oem_%u"), which doesn't check that the
whole name was consumed and also accepts a sign or leading whitespace,
so names like "oem_2900x" and "oem_+2900" resolved to uid 2900. An
out-of-range value was also undefined behavior.

Require only digits after "oem_" and parse them with strtoull, rejecting
trailing characters and values that don't fit in id_t.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

platform_bionic: grp_pwd.cpp: oem_id_from_name accepts trailing characters

1 participant