Skip to content

Commit

Permalink
Reject line protocol that terminates with '-'
Browse files Browse the repository at this point in the history
Fixes issue #4272.
  • Loading branch information
otoolep committed Oct 2, 2015
1 parent 08d299f commit 59bbc5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- [#4237](https://github.com/influxdb/influxdb/issues/4237): DERIVATIVE() edge conditions
- [#4263](https://github.com/influxdb/influxdb/issues/4263): derivative does not work when data is missing
- [#4293](https://github.com/influxdb/influxdb/pull/4293): Ensure shell is invoked when touching PID file. Thanks @christopherjdickson
- [#4296](https://github.com/influxdb/influxdb/pull/4296): Reject line protocol ending with '-'. Fixes [#4272](https://github.com/influxdb/influxdb/issues/4272)

## v0.9.4 [2015-09-14]

Expand Down
4 changes: 4 additions & 0 deletions models/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ func scanNumber(buf []byte, i int) (int, error) {
// Is negative number?
if i < len(buf) && buf[i] == '-' {
i += 1
// There must be more characters now, as just '-' is illegal.
if i == len(buf) {
return i, fmt.Errorf("invalid number")
}
}

// how many decimal points we've see
Expand Down
8 changes: 7 additions & 1 deletion models/points_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,18 @@ func TestParsePointNegativeWrongPlace(t *testing.T) {
}
}

func TestParsePointOnlyNegativeSign(t *testing.T) {
_, err := models.ParsePointsString(`cpu,host=serverA,region=us-west value=-`)
if err == nil {
t.Errorf(`ParsePoints("%s") mismatch. got nil, exp error`, `cpu,host=serverA,region=us-west value=-`)
}
}

func TestParsePointFloatMultipleDecimals(t *testing.T) {
_, err := models.ParsePointsString(`cpu,host=serverA,region=us-west value=1.1.1`)
if err == nil {
t.Errorf(`ParsePoints("%s") mismatch. got nil, exp error`, `cpu,host=serverA,region=us-west value=1.1.1`)
}
println(err.Error())
}

func TestParsePointInteger(t *testing.T) {
Expand Down

0 comments on commit 59bbc5c

Please sign in to comment.