-
Notifications
You must be signed in to change notification settings - Fork 685
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
Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64190 #1240
Conversation
b51d900
to
d152bb2
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev #1240 +/- ##
==========================================
- Coverage 82.71% 82.70% -0.02%
==========================================
Files 159 159
Lines 20329 20338 +9
Branches 7687 7693 +6
==========================================
+ Hits 16816 16821 +5
+ Misses 2904 2895 -9
- Partials 609 622 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I thought the pattern is to reject invalid options instead of allowing to
create them and then having multiple checks all over different get methods
(and not only getters. Add* methods should also handle the corrupted data).
…On Fri, Nov 17, 2023, 08:12 seladb ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In Packet++/src/SomeIpSdLayer.cpp
<#1240 (comment)>:
> + size_t offsetOption = sizeof(someipsdhdr) + sizeof(uint32_t) + getLenEntries(data) + sizeof(uint32_t);
+ size_t lenOptions = getLenOptions(data);
+ uint32_t len = 0;
+ while (len < lenOptions)
+ {
+ if (len + sizeof(uint16_t) + 3 * sizeof(uint8_t) > lenOptions)
+ return false;
+
+ uint32_t lenOption = be16toh(*((uint16_t *)(data + offsetOption + len))) + 3 * sizeof(uint8_t);
+ len += lenOption;
+ if (len > lenOptions) // the last must be equal to lenOptions
+ return false;
+ }
it's a bit weird to parse all the options in isDataValid(). Maybe we
should fix countOptions() and findOption() to avoid going into
non-allocated memory?
—
Reply to this email directly, view it on GitHub
<#1240 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWINCMX4TPGEUYVQBGYXNETYE4E7BAVCNFSM6AAAAAA7MTWO56VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMZWGE3TQOJTGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yes, usually we prefer to reject invalid layers using the checks in |
OK, ignoring the corrupted tail sounds easy, but there are all kind of fields in the beginning that describe the size of remaining data. Handling such data means to remember to use the "trimmed" sizes instead. Also this "tolerate and fix" led to #1237. In short the construction of |
I agree it's probably wrong to do this calculation in the c'tor. A lazy calculation might have been better + making
I agree that when possible we shouldn't use the "tolerate and fix" approach because of the reasons you mentioned. However, protocol parsing is not always easy, and for some protocols verifying that the data is fully valid would require a very complex logic in Going back to this specific case - I think the addition to
Please let me know what you think |
Please take a look. |
No description provided.