X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=passwd.go;h=9b4b78cbe48e089718e2cede75cc36027eb439fc;hb=1002c514a8530bb6608c556b4446e853be390917;hp=c9f4409c2bbb013f99631d251389f2e8d2e85de9;hpb=a3031f694a0d58d23d383346ee848a6c78a1e4b9;p=nsscash%2Fnsscash.git diff --git a/passwd.go b/passwd.go index c9f4409..9b4b78c 100644 --- a/passwd.go +++ b/passwd.go @@ -1,6 +1,6 @@ // Parse /etc/passwd files and serialize them -// Copyright (C) 2019 Simon Ruderich +// Copyright (C) 2019-2020 Simon Ruderich // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -54,6 +54,11 @@ func ParsePasswds(r io.Reader) ([]Passwd, error) { t, err := s.ReadString('\n') if err != nil { if err == io.EOF { + if t != "" { + return nil, fmt.Errorf( + "no newline in last line: %q", + t) + } break } return nil, err