Avoid out of bounds exception if checksum is ok but data is crap
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
51d6e75f0c
commit
74c37c2fc9
1 changed files with 6 additions and 0 deletions
6
main.go
6
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -155,6 +156,11 @@ func treatLine(line []byte, legacyMode bool) (key string, horodate *time.Time, d
|
|||
|
||||
fields := bytes.Fields(line)
|
||||
|
||||
if len(fields) < 2 {
|
||||
err = fmt.Errorf("Invalid number of fields in line")
|
||||
return
|
||||
}
|
||||
|
||||
key = string(fields[0])
|
||||
|
||||
horodate, err = getHorodate(&fields)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue