parseDkHeader() crashes when flag does not have "=" delimeter
This commit is contained in:
Stéphane Depierrepont aka Toorop
2015-12-11 08:37:47 +01:00
parent fa48964628
commit 5359189bbe
2 changed files with 19 additions and 11 deletions

View File

@@ -322,6 +322,11 @@ func parseDkHeader(header string) (dkh *dkimHeader, err error) {
fs := strings.Split(val, ";")
for _, f := range fs {
flagData := strings.SplitN(f, "=", 2)
// https://github.com/toorop/go-dkim/issues/2
// if flag is not in the form key=value (eg doesn't have "=")
if len(flagData) != 2 {
return nil, ErrDkimHeaderBadFormat
}
flag := strings.ToLower(strings.TrimSpace(flagData[0]))
data := strings.TrimSpace(flagData[1])
switch flag {