fork of go-gitdiff with jj support

Fix out-of-bounds panic parsing timestamps (#28)

Found by go-fuzz.

authored by Billy Keyes and committed by GitHub b6a90110 53bcdf7e

Changed files
+9 -1
gitdiff
+1 -1
gitdiff/file_header.go
··· 527 527 528 528 // a valid timestamp can have optional ':' in zone specifier 529 529 // remove that if it exists so we have a single format 530 - if ts[len(ts)-3] == ':' { 530 + if len(ts) >= 3 && ts[len(ts)-3] == ':' { 531 531 ts = ts[:len(ts)-3] + ts[len(ts)-2:] 532 532 } 533 533
+8
gitdiff/file_header_test.go
··· 724 724 Input: "+++ file.txt\t2019-03-21 12:34:56.789 -0700\n", 725 725 Output: false, 726 726 }, 727 + "notTimestamp": { 728 + Input: "+++ file.txt\trandom text\n", 729 + Output: false, 730 + }, 731 + "notTimestampShort": { 732 + Input: "+++ file.txt\t0\n", 733 + Output: false, 734 + }, 727 735 } 728 736 729 737 for name, test := range tests {