Reject line protocol that terminates with '-'

Fixes issue #4272.
pull/4296/head
Philip O'Toole 2015-10-01 20:45:10 -07:00
parent 08d299f6c7
commit 59bbc5c8e3
3 changed files with 12 additions and 1 deletions

View File

@ -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]

View File

@ -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

View File

@ -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) {