mirror of
https://github.com/FiloSottile/age.git
synced 2026-09-05 07:36:55 +00:00
internal/format: reject headers without recipient stanzas
Reported by Joe Doyle of Trail of Bits.
This commit is contained in:
@@ -135,6 +135,9 @@ func (r *Stanza) Marshal(w io.Writer) error {
|
||||
}
|
||||
|
||||
func (h *Header) MarshalWithoutMAC(w io.Writer) error {
|
||||
if len(h.Recipients) == 0 {
|
||||
return errors.New("no recipient stanzas")
|
||||
}
|
||||
if _, err := io.WriteString(w, intro); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -348,6 +351,9 @@ func Parse(input io.Reader) (*Header, io.Reader, error) {
|
||||
}
|
||||
h.Recipients = append(h.Recipients, s)
|
||||
}
|
||||
if len(h.Recipients) == 0 {
|
||||
return nil, nil, errorf("no recipient stanzas")
|
||||
}
|
||||
|
||||
// If input is a bufio.Reader, rr might be equal to input because
|
||||
// bufio.NewReader short-circuits. In this case we can just return it (and
|
||||
|
||||
Reference in New Issue
Block a user