user: TestGetAdditionalGroups/group_entry_with_out-of-range_gid fails on 32-bit architectures (GOARCH=386 / arm)
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- go
调研方向
先查看 user/user_test.go 中 TestGetAdditionalGroups 附近的代码,以及 user/user.go 中 parseParts 附近的代码,然后运行 GOARCH=386 go test -v . -run "TestGetAdditionalGroups/group_entry_with_out-of-range_gid"。跟踪 GID 在 32 位和 64 位架构上的解析方式。完成标准是:超出范围的组条目在两种架构上都能可靠地返回预期错误,同时不会导致 User 或 Group ID 解析出现回归。
由索引模型根据 Issue 内容生成。
描述
Description
When running tests in github.com/moby/sys/user on 32-bit architectures (e.g. GOARCH=386 or GOARCH=arm), TestGetAdditionalGroups/group_entry_with_out-of-range_gid fails:
=== RUN TestGetAdditionalGroups
=== RUN TestGetAdditionalGroups/group_entry_with_out-of-range_gid
user_test.go:651: Parse(struct { doc string; groups []string; expected []int; hasError bool }{doc:"group entry with out-of-range gid", groups:[]string{"toolarge"}, expected:[]int(nil), hasError:true}) expects error but has none
--- FAIL: TestGetAdditionalGroups (0.01s)
--- FAIL: TestGetAdditionalGroups/group_entry_with_out-of-range_gid (0.00s)
FAIL github.com/moby/sys/user 0.008s
Steps to Reproduce
cd user
GOARCH=386 go test -v . -run "TestGetAdditionalGroups/group_entry_with_out-of-range_gid"
Root Cause Analysis
-
In
user/user_test.go, the test definesgroupContentwith:toolarge:x:2147483648:where
2147483648ismath.MaxInt32 + 1. -
In
user/user.go,parseParts()parses GID entries into*intvia:case *int: *e, _ = strconv.Atoi(string(p))Conversion errors returned by
strconv.Atoiare explicitly ignored (_). -
On 64-bit systems (
intisint64),strconv.Atoi("2147483648")succeeds and sets*e = 2147483648.GetAdditionalGroups()then checksif g.Gid < minID || g.Gid > maxID(wheremaxIDis2147483647), correctly returningErrRange. -
On 32-bit systems (
intisint32),strconv.Atoi("2147483648")overflowsint32and returnsstrconv.ErrRangewhile setting*e = math.MaxInt32(2147483647). Because the conversion error is discarded,g.Gidbecomes2147483647. Since2147483647 <= maxID,GetAdditionalGroups()considers the GID valid, does not return an error, and the test fails.
Suggested Fix
parseParts (or Group.Gid / User.Uid / User.Gid parsing) should either:
- Parse IDs as
int64(e.g.strconv.ParseInt(string(p), 10, 64)) or validatestrconv.ErrRangebefore truncating/converting toint, or - Check whether the string value exceeds
maxID(or check forstrconv.ErrRange) when validating group/user entries so that 32-bit platforms reject out-of-range values consistently with 64-bit platforms.
- 主要语言
- Go
- 星标
- 103
- 派生
- 64
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
moby/sys 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
devices: ignore .incus-mounts in GetDevices可能已有人在做 @SashaMIT 于 13 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
-
[userns-remap] Bug: ToHost incorrectly maps non-root container UID to root when it collides with RootPair可能已有人在做 @okhowang 于 79 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
-
capability.LastCap fails when /proc/sys/kernel/cap_last_cap is unavailable可能已有人在做 @kolyshkin 于 2 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 50/100
-
user: parseLine silently ignores uid/gid conversion errors, malformed ids parse as 0可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
相似的 Issue
-
feature suggestion
难度 2/5 1-3 小时 新手友好度 88/100
openvibely/openvibely#1526 ·
维护者通常 1 天内回复
-
docs good first issue
难度 2/5 1-3 小时 新手友好度 85/100
Usenova-Labs/usenova-backend#36 ·
维护者通常 1 天内回复
-
bug raised-by:verifier
难度 2/5 1-3 小时 新手友好度 76/100
medici-finance/assay#4177 ·
维护者通常 1 天内回复
-
bug: admin user creation silently ignores role可能已有人在做 @bfs2021 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
eugenioenko/autentico#553 ·
维护者通常 1 天内回复
-
sidecar: --moriio-parallel-dispatch omits remote_request_id, so a vLLM NixlPushConnector decode dies with KeyError可能已有人在做 @xintin 今天认领。 未关闭kind/bug needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
llm-d/llm-d-router#3607 ·
维护者通常 1 天内回复