mirror of
https://github.com/FiloSottile/age.git
synced 2026-03-11 08:55:41 +00:00
age,cmd/age: improve error messages for mixed up identities/recipients
Not sure why ParseRecipients was hiding errors, when ParseIdentities doesn't. For #643
This commit is contained in:
parent
2e0f1efe4d
commit
44a4fcc27b
2 changed files with 7 additions and 3 deletions
|
|
@ -91,6 +91,9 @@ func parseRecipientsFile(name string) ([]age.Recipient, error) {
|
|||
warningf("recipients file %q: ignoring unsupported SSH key of type %q at line %d", name, t, n)
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, "AGE-") {
|
||||
return nil, fmt.Errorf("%q: error at line %d: apparent identity found in recipients file", name, n)
|
||||
}
|
||||
// Hide the error since it might unintentionally leak the contents
|
||||
// of confidential files.
|
||||
return nil, fmt.Errorf("%q: malformed recipient at line %d", name, n)
|
||||
|
|
@ -235,6 +238,9 @@ func parseIdentities(f io.Reader) ([]age.Identity, error) {
|
|||
}
|
||||
i, err := parseIdentity(line)
|
||||
if err != nil {
|
||||
if strings.HasPrefix(line, "age1") {
|
||||
return nil, fmt.Errorf("error at line %d: apparent recipient found in identities file", n)
|
||||
}
|
||||
return nil, fmt.Errorf("error at line %d: %v", n, err)
|
||||
}
|
||||
ids = append(ids, i)
|
||||
|
|
|
|||
4
parse.go
4
parse.go
|
|
@ -87,9 +87,7 @@ func ParseRecipients(f io.Reader) ([]Recipient, error) {
|
|||
}
|
||||
r, err := parseRecipient(line)
|
||||
if err != nil {
|
||||
// Hide the error since it might unintentionally leak the contents
|
||||
// of confidential files.
|
||||
return nil, fmt.Errorf("malformed recipient at line %d", n)
|
||||
return nil, fmt.Errorf("error at line %d: %v", n, err)
|
||||
}
|
||||
recs = append(recs, r)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue