Fix a panic when a tag value was empty

A panic would happen if you wrote the following:
    cpu,host=

There was a missing bounds check when scanning the tag value.

Fixes #5262.
pull/5370/head
Jonathan A. Sternberg 2016-01-15 17:07:34 -05:00
parent e036a4e69b
commit 8eac790eab
3 changed files with 3 additions and 1 deletions

View File

@ -25,6 +25,7 @@
- [#5186](https://github.com/influxdata/influxdb/pull/5186): Fix database creation with retention statement parsing. Fixes [#5077](https://github.com/influxdb/influxdb/issues/5077). Thanks @pires - [#5186](https://github.com/influxdata/influxdb/pull/5186): Fix database creation with retention statement parsing. Fixes [#5077](https://github.com/influxdb/influxdb/issues/5077). Thanks @pires
- [#5193](https://github.com/influxdata/influxdb/issues/5193): Missing data a minute before current time. Comes back later. - [#5193](https://github.com/influxdata/influxdb/issues/5193): Missing data a minute before current time. Comes back later.
- [#5350](https://github.com/influxdata/influxdb/issues/5350): 'influxd backup' should create backup directory - [#5350](https://github.com/influxdata/influxdb/issues/5350): 'influxd backup' should create backup directory
- [#5262](https://github.com/influxdata/influxdb/issues/5262): Fix a panic when a tag value was empty.
## v0.9.6 [2015-12-09] ## v0.9.6 [2015-12-09]

View File

@ -455,7 +455,7 @@ func scanTagsKey(buf []byte, i int) (int, error) {
// scanTagsValue scans each character in a tag value. // scanTagsValue scans each character in a tag value.
func scanTagsValue(buf []byte, i int) (int, int, error) { func scanTagsValue(buf []byte, i int) (int, int, error) {
// Tag value cannot be empty. // Tag value cannot be empty.
if buf[i] == ',' || buf[i] == ' ' { if i >= len(buf) || buf[i] == ',' || buf[i] == ' ' {
// cpu,tag={',', ' '} // cpu,tag={',', ' '}
return -1, i, fmt.Errorf("missing tag value") return -1, i, fmt.Errorf("missing tag value")
} }

View File

@ -253,6 +253,7 @@ func TestParsePointMissingTagValue(t *testing.T) {
examples := []string{ examples := []string{
`cpu,host`, `cpu,host`,
`cpu,host,`, `cpu,host,`,
`cpu,host=`,
`cpu,host value=1i`, `cpu,host value=1i`,
`cpu,host=serverA,region value=1i`, `cpu,host=serverA,region value=1i`,
`cpu,host=serverA,region= value=1i`, `cpu,host=serverA,region= value=1i`,