forked from dvyukov/go-fuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (34 loc) · 835 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2015 Dmitry Vyukov. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package mail
import (
"bytes"
"io"
"io/ioutil"
"net/mail"
"reflect"
)
func Fuzz(data []byte) int {
msg, err := mail.ReadMessage(bytes.NewReader(data))
if err != nil {
return 0
}
msg.Header.AddressList("to")
msg.Header.Date()
if addr, err := mail.ParseAddress(msg.Header.Get("from")); err == nil {
addr1, err := mail.ParseAddress(addr.String())
if false {
// https://github.com/golang/go/issues/11292
// https://github.com/golang/go/issues/11293
// https://github.com/golang/go/issues/11294
if err != nil {
panic(err)
}
if !reflect.DeepEqual(addr, addr1) {
panic("addr changed")
}
}
}
io.Copy(ioutil.Discard, msg.Body)
return 1
}