Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Fix bad pointer arithmetic #474

Merged
merged 1 commit into from
Apr 16, 2019
Merged

Fix bad pointer arithmetic #474

merged 1 commit into from
Apr 16, 2019

Conversation

bnoordhuis
Copy link
Member

The bad arithmetic didn't result in wrong or insecure behavior
(there were no out-of-bound accesses and forward progress was
still being made because of the outer loop) but it did regress
the performance of header field parsing rather massively.

Taking the test suite as an example: the inner fast path loop
was skipped over 4.4 million times, falling back to the outer
slow path loop. After this commit that only happens about
2,000 times - a 2,200-fold reduction.

Fixes: #473

Copy link
Member

@indutny indutny left a comment

Choose a reason for hiding this comment

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

LGTM. Good catch!

The bad arithmetic didn't result in wrong or insecure behavior
(there were no out-of-bound accesses and forward progress was
still being made because of the outer loop) but it did regress
the performance of header field parsing rather massively.

Taking the test suite as an example: the inner fast path loop
was skipped over 4.4 million times, falling back to the outer
slow path loop. After this commit that only happens about
2,000 times - a 2,200-fold reduction.

Fixes: nodejs#473
PR-URL: nodejs#474
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
@bnoordhuis bnoordhuis closed this Apr 16, 2019
@bnoordhuis bnoordhuis deleted the fix473 branch April 16, 2019 06:32
@bnoordhuis bnoordhuis merged commit c7d4925 into nodejs:master Apr 16, 2019
ploxiln pushed a commit to ploxiln/http-parser that referenced this pull request Apr 16, 2019
The bad arithmetic didn't result in wrong or insecure behavior,
but it did regress the performance of header field parsing massively.

Taking the test suite as an example: the inner fast path loop
was skipped over 4.4 million times, falling back to the outer
slow path loop. After this commit that only happens about
2,000 times - a 2,200-fold reduction.

Fixes: nodejs#473
PR-URL: nodejs#474

also fix -Wsign-compare warning that manifests itself with gcc 7.4.0+

Fixes: nodejs#471
PR-URL: nodejs#472

Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad pointer arithmetic in header field parsing
2 participants