Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panics found via go-fuzz #3570

Merged
merged 1 commit into from
Aug 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -117,7 +117,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 @@ -222,6 +229,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