Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libct/user: fix parsing long /etc/group lines #3062

Merged
merged 3 commits into from
Jul 8, 2021

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Jul 2, 2021

Lines in /etc/group longer than 64 characters breaks the current
implementation of group parser. This is caused by bufio.Scanner
buffer limit.

Fix by re-using the fix for a similar problem in golang os/user,
namely https://go-review.googlesource.com/c/go/+/283601
(fixing a similar bug in golang os/user, golang/go#43636).

Add some tests.

Fixes: #3036

Reported-by: @erict-square
Co-authored-by: @andreybokhanko
Signed-off-by: Kir Kolyshkin kolyshkin@gmail.com

Proposed changelog entry

Bugfixes:
* Fixed "unable to find groups ... token too long" error with /etc/group containing lines longer than 64K characters (#3036)

1.0 backport: #3079

kolyshkin added 2 commits July 2, 2021 12:25
Every []byte to string conversion results in a new allocation.
Avoid some by using []byte more.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Same as in other places (other parsers here, as well as golang os/user
parser and glibc parser all tolerate extra space at BOL and EOL).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Lines in /etc/group longer than 64 characters breaks the current
implementation of group parser. This is caused by bufio.Scanner
buffer limit.

Fix by re-using the fix for a similar problem in golang os/user,
namely https://go-review.googlesource.com/c/go/+/283601.

Add some tests.

Co-authored-by: Andrey Bokhanko <andreybokhanko@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin mentioned this pull request Jul 8, 2021
Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

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

LGTM.

@cyphar cyphar closed this in 262f294 Jul 8, 2021
@cyphar cyphar merged commit 262f294 into opencontainers:master Jul 8, 2021
@kolyshkin kolyshkin added backport/1.0-done A PR in main branch which has been backported to release-1.0 and removed backport/1.0-todo A PR in main branch which needs to be backported to release-1.0 labels Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.0-done A PR in main branch which has been backported to release-1.0 impact/changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

starting container process caused: setup user: unable to find <user>: bufio.Scanner: token too long: unknown.
3 participants