[go: nahoru, domu]

Skip to content

Commit

Permalink
getPasswd: Check full prefix of line for username (#81)
Browse files Browse the repository at this point in the history
This fixes #80 where the username is checked with Contains, resulting in improper parsing when a username is a suffix of another username.
  • Loading branch information
Matir committed Oct 1, 2020
1 parent 89042bf commit 369e63c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion google_guest_agent/non_windows_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func getPasswd(user string) (*passwdEntry, error) {
colon := []byte{':'}

parse := func(line []byte) (*passwdEntry, error) {
if !bytes.Contains(line, prefix) || bytes.Count(line, colon) < 6 {
if !bytes.HasPrefix(line, prefix) || bytes.Count(line, colon) < 6 {
return nil, nil
}
// kevin:x:1005:1006::/home/kevin:/usr/bin/zsh
Expand Down

0 comments on commit 369e63c

Please sign in to comment.