Repository navigation
inspector: fix ctype UB and stoi overflow in session id parsing - #65763
Conversation
|
Review requested:
|
|
Caution AgentScan found account activity patterns that may be consistent with |
61336d0 to
ce98e53
Compare
|
Please make sure you have read and understood the following documents: |
|
I have read and understood all of the linked documents -- the contributing guide, pull request guide, AI use policy, automation policy, and Code of Conduct. To be transparent: I used AI tooling to help identify these bugs and draft the initial code, but I personally reviewed each change, understand what it does, and take responsibility for it. I did not use automated tooling to open this PR -- I opened it manually after reviewing the diff. Happy to discuss any of the specific changes if that would help. |
ce98e53 to
ab3faa4
Compare
This comment was marked as resolved.
This comment was marked as resolved.
669354e to
9d651d8
Compare
|
Thanks for checking. Two CI failures, both now fixed:
Force-pushed the updated commit. CI should be clean now. |
9d651d8 to
3783f45
Compare
|
|
||
| const headersMap = this[kOutHeaders]; | ||
| const headers = {}; | ||
| const headers = { __proto__: null }; |
There was a problem hiding this comment.
this alone would likely need a full http CI benchmark
There was a problem hiding this comment.
I reverted it for now, happy to revisit in a separate PR with benchmarks.
3783f45 to
87a5ab0
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65763 +/- ##
==========================================
+ Coverage 90.52% 90.59% +0.07%
==========================================
Files 803 802 -1
Lines 285110 286660 +1550
Branches 55037 55372 +335
==========================================
+ Hits 258101 259705 +1604
+ Misses 17143 17061 -82
- Partials 9866 9894 +28
🚀 New features to boost your workflow:
|
|
Thanks for flagging this. The mismatch was from before I replaced |
This comment was marked as resolved.
This comment was marked as resolved.
- cast the isdigit argument to unsigned char, since passing a negative char is undefined behavior - replace stoi with from_chars, since stoi throws on overflow and the build uses -fno-exceptions - cast to unsigned int before the left shift, since shifting a large signed value is undefined behavior Signed-off-by: VirajMishra1 <viraj.mishra.81@gmail.com>
87a5ab0 to
71ba7c0
Compare
|
Rebased on main. The WebSocket frame bounds part was already fixed on main in 93df195, so I dropped it and updated the title and description. The PR now only touches the session id parsing in |
|
Landed in f97d451 |
Fixes three small issues in how the inspector parses the target session id in
inspector_io.cc:::isdigitcall now takes anunsigned char. Passing a plaincharis undefined behavior when the value is negative, which happens with non-ASCII input.std::stoiis replaced withstd::from_chars. The string is already checked to be all digits, so the only difference is overflow:stoithrows, which doesn't build with-fno-exceptions, andfrom_charsreports an error code that we now check.target_session_idis cast tounsigned intbefore the<< 16, since left-shifting a large signed value is undefined behavior.This PR also used to fix the WebSocket frame bounds check in
inspector_socket.cc, but that was fixed on main in 93df195, so I dropped it when rebasing.I used AI tooling to help find these and draft the first version. I reviewed and understand each change and I am responsible for it.