etcdctl: fix slice bounds trimming single-quoted args#21307
etcdctl: fix slice bounds trimming single-quoted args#21307huajianxiaowanzi wants to merge 3 commits intoetcd-io:mainfrom
Conversation
|
Hi @huajianxiaowanzi. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
Fixes an indexing bug in etcdctl argument parsing where trimming single-quoted arguments used the number of parsed args (len(args)) instead of the length of the specific argument string (len(args[i])), which could cause slice-bounds panics.
Changes:
- Correct single-quote trimming logic in
Argifyto slice based on the current token length.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: huajianxiaowanzi <1695316070@qq.com>
aad1a0b to
5598893
Compare
| if args[i][0] == '\'' { | ||
| // 'single-quoted string' | ||
| args[i] = args[i][1 : len(args)-1] | ||
| args[i] = args[i][1 : len(args[i])-1] |
There was a problem hiding this comment.
Good catch.
Can you please add an unit test?
There was a problem hiding this comment.
Unit test have been added.
Could you please take a look?
Signed-off-by: huajianxiaowanzi <1695316070@qq.com>
|
/ok-to-test |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
... and 21 files with indirect coverage changes @@ Coverage Diff @@
## main #21307 +/- ##
==========================================
+ Coverage 68.37% 68.44% +0.06%
==========================================
Files 428 428
Lines 35262 35262
==========================================
+ Hits 24110 24134 +24
+ Misses 9751 9728 -23
+ Partials 1401 1400 -1 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Signed-off-by: huajianxiaowanzi <1695316070@qq.com>
|
/retest |
|
@huajianxiaowanzi: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
The failure has nothing to do with this PR. It's a known issue #21298 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, huajianxiaowanzi The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The logic for handling single quotes erroneously used len(args) (the length of the entire slice) instead of len(args[i]) (the length of the current string). This leads to incorrect slicing logic or potential index-out-of-bounds panics.