Skip to content

buffer: fix handling of empty string prepends.#6042

Merged
htuch merged 1 commit intoenvoyproxy:masterfrom
htuch:buffer-empty-prepend
Feb 25, 2019
Merged

buffer: fix handling of empty string prepends.#6042
htuch merged 1 commit intoenvoyproxy:masterfrom
htuch:buffer-empty-prepend

Conversation

@htuch
Copy link
Copy Markdown
Member

@htuch htuch commented Feb 24, 2019

Prepending an empty string seems to mess up libevent internally.
evbuffer_prepend doesn't have a check for empty (unlike evbuffer_prepend_buffer
which does). This then results in an allocation of an empty chain, which causes
problems with a following move/append. This only seems to happen the the
original buffer was created via addBufferFragment(), this forces the code
execution path in evbuffer_prepend related to immutable buffers.

Fixes oss-fuzz issue https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13263.

Risk level: Low
Testing: Corpus entry and unit test added.

Signed-off-by: Harvey Tuch htuch@google.com

Prepending an empty string seems to mess up libevent internally.
evbuffer_prepend doesn't have a check for empty (unlike evbuffer_prepend_buffer
which does). This then results in an allocation of an empty chain, which causes
problems with a following move/append. This only seems to happen the the
original buffer was created via addBufferFragment(), this forces the code
execution path in evbuffer_prepend related to immutable buffers.

Fixes oss-fuzz issue https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13263.

Risk level: Low
Testing: Corpus entry and unit test added.

Signed-off-by: Harvey Tuch <htuch@google.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

@htuch htuch merged commit c9e01ed into envoyproxy:master Feb 25, 2019
@htuch htuch deleted the buffer-empty-prepend branch February 25, 2019 02:38
htuch added a commit to htuch/envoy that referenced this pull request Feb 25, 2019
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
Prepending an empty string seems to mess up libevent internally.
evbuffer_prepend doesn't have a check for empty (unlike evbuffer_prepend_buffer
which does). This then results in an allocation of an empty chain, which causes
problems with a following move/append. This only seems to happen the the
original buffer was created via addBufferFragment(), this forces the code
execution path in evbuffer_prepend related to immutable buffers.

Fixes oss-fuzz issue https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13263.

Risk level: Low
Testing: Corpus entry and unit test added.

Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants