Skip to content

Commit

Permalink
Prevent out of memory range slices from being created
Browse files Browse the repository at this point in the history
If the hinted handoff segment is corrupt, the size read could be
invalid and attempting to create a slice using that size causes
a panic.  Ideally, we'd have a checksum on the seqment record but
for now just return an error when the size is larger than the
segment file.

Fixes #3687
  • Loading branch information
jwilder committed Aug 17, 2015
1 parent 1548f62 commit 7cf31a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ There are breaking changes in this release. Please see the *Features* section be
- [#3672](https://github.com/influxdb/influxdb/pull/3672): Reduce in-memory index by 20%-30%
- [#3673](https://github.com/influxdb/influxdb/pull/3673): Improve query performance by removing unnecessary tagset sorting.
- [#3676](https://github.com/influxdb/influxdb/pull/3676): Improve query performance by memomizing mapper output keys.
- [#3687](https://github.com/influxdb/influxdb/issues/3687): Fix panic: runtime error: makeslice: len out of range in hinted handoff

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

Expand Down
4 changes: 4 additions & 0 deletions services/hh/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ func (l *segment) current() ([]byte, error) {
}
l.currentSize = int64(sz)

if int64(sz) > l.maxSize {
return nil, fmt.Errorf("record size out of range: max %d: got %d", l.maxSize, sz)
}

b := make([]byte, sz)
if err := l.readBytes(b); err != nil {
return nil, err
Expand Down

0 comments on commit 7cf31a7

Please sign in to comment.