Skip to content
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 In some cases, pkt_num_offset greater than left can cause a panic #426

Closed
wants to merge 3 commits into from

Conversation

jiangema
Copy link
Contributor

resolve #Issue 425

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.19%. Comparing base (d1057f7) to head (79bb422).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #426      +/-   ##
===========================================
+ Coverage    94.78%   95.19%   +0.41%     
===========================================
  Files           50       50              
  Lines        34297    34301       +4     
===========================================
+ Hits         32507    32653     +146     
+ Misses        1790     1648     -142     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1708,7 +1708,7 @@ impl Connection {
}

// Encode packet number
let len = packet::encode_packet_num(pkt_num, pkt_num_len, &mut out[pkt_num_offset..left])?;
let len = packet::encode_packet_num(pkt_num, pkt_num_len, &mut out[pkt_num_offset..])?;
Copy link
Collaborator

@iyangsj iyangsj Nov 15, 2024

Choose a reason for hiding this comment

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

此处改为如下更好(可限制encode_packet_num()操作的缓冲区范围并拦截可能意外引入的错误)

&mut out[pkt_num_offset..pkt_num_offset+ pkt_num_len]

注:line 1700~line 1706的检查,可以保证 out的长度大于 pkt_num_offset+pkt_num_len

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我重新建了一个分支,修改后又提了一个pr

@jiangema jiangema closed this Nov 15, 2024
@jiangema jiangema deleted the fix-slice-index branch November 15, 2024 11:18
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