-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
&max-size will overread and only raise error afterwards #1815
Comments
What happens here is that we set up two dependent limited views into the input stream:
This fails since when calling SUBCASE("limited view inherits limit") {
auto input = "1234567890"_b;
auto stream = Stream(input);
auto view = stream.view();
auto limit1 = view.limit(5U);
REQUIRE_EQ(limit1.size(), 5U);
auto limit2 = limit1.limit(input.size());
REQUIRE_EQ(limit2.size(), 5U);
} The fix would probably be to only ever decrease the size of a |
The documented semantics of `View::limit` are that it creates a new view with equal or smaller size. In contrast to that we would still have allowed to expand views with more calls `limit` again as well. This patch changes the implementation of `View::limit` so it can only ever make a `View` smaller. Closes #1815.
The documented semantics of `View::limit` are that it creates a new view with equal or smaller size. In contrast to that we would still have allowed to expand views with more calls `limit` again as well. This patch changes the implementation of `View::limit` so it can only ever make a `View` smaller. We also tweak the implementation of the check for consumed `&size` when used together with `&eod`: if the `&size` was already nested in a limited view a larger `&size` value could previously extend the view so the `&eod` effectively was ignored. Since we now do not extend the `View` anymore we need to only activate the check for consumed `&size` if `&eod` was not specified since in this case the user communicated that they are fine with consuming less data. Closes #1815.
The documented semantics of `View::limit` are that it creates a new view with equal or smaller size. In contrast to that we would still have allowed to expand views with more calls `limit` again as well. This patch changes the implementation of `View::limit` so it can only ever make a `View` smaller. We also tweak the implementation of the check for consumed `&size` when used together with `&eod`: if the `&size` was already nested in a limited view a larger `&size` value could previously extend the view so the `&eod` effectively was ignored. Since we now do not extend the `View` anymore we need to only activate the check for consumed `&size` if `&eod` was not specified since in this case the user communicated that they are fine with consuming less data. Closes #1815. (cherry picked from commit 44d87b2)
The
&max-size
attribute will happily allow inner units to over-read the data from the input stream till they are done, including raising hooks (or zeek events) - only raising an error after all parsing is finished.Example:
This obviously is a problem, especially in cases when one parses a protocol that specifies unit-lengths itself.
To give a real-world example: This bug was found while examining a test-failure fo the TLS testsuite. In that case, an inner field specifies a much-too-large-length, exceeding the size of the outer fields by several kilobytes. As this overread seems to exceed the amount of data remaining in this connection, no error is ever raised.
The text was updated successfully, but these errors were encountered: