Skip to content

[WIP] user: skip malformed and empty lines#230

Draft
thaJeztah wants to merge 3 commits into
moby:mainfrom
thaJeztah:parseparts_err
Draft

[WIP] user: skip malformed and empty lines#230
thaJeztah wants to merge 3 commits into
moby:mainfrom
thaJeztah:parseparts_err

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

No description provided.

@thaJeztah thaJeztah force-pushed the parseparts_err branch 2 times, most recently from 1b8a8f3 to 36088f5 Compare June 30, 2026 19:05
thaJeztah and others added 2 commits July 8, 2026 14:12
Return an error when failing to parse numeric values instead of silently
discarding them.

Co-authored-by: Mickael Emirkanian <mickael.emirkanian@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah changed the title [WIP] user: skip malformed lines [WIP] user: skip malformed and empty lines Jul 8, 2026
Comment thread user/user.go
Comment on lines +157 to +161
ok, err := parseLine(line, &p.Name, &p.Pass, &p.Uid, &p.Gid, &p.Gecos, &p.Home, &p.Shell)
if err != nil || !ok {
// Skip malformed and empty lines, and don't consider them.
continue
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly also skip zero-records;

if p == (User{}) {
    continue
}

Comment thread user/user.go
Comment on lines +220 to 227
ok, err := parseLine(line, &p.Name, &p.Pass, &p.Gid, &p.List)
if err != nil || !ok {
// Skip malformed and empty lines, and don't consider them.
continue
}

if filter == nil || filter(p) {
out = append(out, p)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well, but Group is not comparable (due to the List []string)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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.

1 participant