Skip to content

Commit

Permalink
Merge pull request #3570 from influxdb/jw-fuzz
Browse files Browse the repository at this point in the history
Fix panics found via go-fuzz
  • Loading branch information
jwilder committed Aug 6, 2015
2 parents 4098de8 + 2d604ac commit 5aacb34
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [#3414](https://github.com/influxdb/influxdb/issues/3414): Shard mappers perform query re-writing
- [#3525](https://github.com/influxdb/influxdb/pull/3525): check if fields are valid during parse time.
- [#3511](https://github.com/influxdb/influxdb/issues/3511): Sending a large number of tag causes panic
- [#3288](https://github.com/influxdb/influxdb/issues/3288): Run go fuzz on the line-protocol input

## v0.9.2 [2015-07-24]

Expand Down
13 changes: 12 additions & 1 deletion tsdb/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ func ParsePointsWithPrecision(buf []byte, defaultTime time.Time, precision strin
}

// lines which start with '#' are comments
if start := skipWhitespace(block, 0); block[start] == '#' {
start := skipWhitespace(block, 0)

// If line is all whitespace, just skip it
if start >= len(block) {
continue
}

if block[start] == '#' {
continue
}

Expand Down Expand Up @@ -229,6 +236,10 @@ func scanKey(buf []byte, i int) (int, []byte, error) {
}

if buf[i] == '=' {
if i-1 < 0 || i-2 < 0 {
return i, buf[start:i], fmt.Errorf("missing tag name")
}

// Check for "cpu,=value" but allow "cpu,a\,=value"
if buf[i-1] == ',' && buf[i-2] != '\\' {
return i, buf[start:i], fmt.Errorf("missing tag name")
Expand Down
24 changes: 23 additions & 1 deletion tsdb/points_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,29 @@ func TestParsePointNoValue(t *testing.T) {
}

if exp := 0; len(pts) != exp {
t.Errorf(`ParsePoints("%s") len mismatch. got %v, exp %vr`, "", len(pts), exp)
t.Errorf(`ParsePoints("%s") len mismatch. got %v, exp %v`, "", len(pts), exp)
}
}

func TestParsePointWhitespaceValue(t *testing.T) {
pts, err := tsdb.ParsePointsString(" ")
if err != nil {
t.Errorf(`ParsePoints("%s") mismatch. got %v, exp nil`, "", err)
}

if exp := 0; len(pts) != exp {
t.Errorf(`ParsePoints("%s") len mismatch. got %v, exp %v`, "", len(pts), exp)
}
}

func TestParsePointSingleEquals(t *testing.T) {
pts, err := tsdb.ParsePointsString("=")
if err == nil {
t.Errorf(`ParsePoints("%s") mismatch. expected error`, "=")
}

if exp := 0; len(pts) != exp {
t.Errorf(`ParsePoints("%s") len mismatch. got %v, exp %v`, "", len(pts), exp)
}
}

Expand Down

0 comments on commit 5aacb34

Please sign in to comment.