fix(vnode): fix signed/unsigned comparison in vnodePreProcessSubmitMsg.#34733
fix(vnode): fix signed/unsigned comparison in vnodePreProcessSubmitMsg.#34733guanshengliang merged 1 commit intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses potential issues arising from signed and unsigned integer comparisons within critical data processing loops in the vnode component. By updating the loop counter types, it ensures correct iteration behavior and prevents unexpected comparisons that could lead to bugs or warnings, thereby improving the robustness and reliability of data submission processing. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
Fixes signed/unsigned comparison warnings in vnode submit preprocessing by adjusting loop counter types during submit request decoding and row/key validation.
Changes:
- Updated loop counter types in
vnodePreProcessSubmitTbData()when iterating decoded column/row counts. - Updated loop counter type in
vnodePreProcessSubmitMsg()to matchnSubmitTbData’s unsigned width.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| for (int32_t iRow = 0; iRow < colData.nVal; iRow++) { | ||
| for (uint32_t iRow = 0; iRow < colData.nVal; iRow++) { |
There was a problem hiding this comment.
colData.nVal is an int32_t (see SColData), but the loop index was changed to uint32_t. This introduces a signed/unsigned comparison and can misbehave if nVal is ever negative (it would be converted to a large unsigned value). Prefer keeping the index signed to match nVal, or explicitly validate that nVal >= 0 before casting both sides to an unsigned type.
| for (uint32_t iRow = 0; iRow < colData.nVal; iRow++) { | |
| for (int32_t iRow = 0; iRow < colData.nVal; iRow++) { |
| } | ||
|
|
||
| for (int32_t iRow = 0; iRow < nRow; ++iRow) { | ||
| for (uint32_t iRow = 0; iRow < nRow; ++iRow) { |
There was a problem hiding this comment.
nRow is decoded as uint64_t, but the loop index was changed to uint32_t. If nRow exceeds UINT32_MAX, iRow will wrap and the loop condition will remain true, leading to an effectively unbounded loop (and likely out-of-bounds reads as pCoder->pos advances). Use a uint64_t/size_t index to match nRow, or cap/validate nRow to a safe maximum before iterating.
| for (uint32_t iRow = 0; iRow < nRow; ++iRow) { | |
| for (uint64_t iRow = 0; iRow < nRow; ++iRow) { |
There was a problem hiding this comment.
Code Review
This pull request aims to fix signed/unsigned comparison warnings by changing the types of loop variables. While the intention is good, one of the changes incorrectly introduces a signed/unsigned mismatch, and another only partially fixes the issue. I've provided suggestions to correct these.
Note: Security Review did not run due to the size of the PR.
| } | ||
|
|
||
| for (int32_t iRow = 0; iRow < colData.nVal; iRow++) { | ||
| for (uint32_t iRow = 0; iRow < colData.nVal; iRow++) { |
| } | ||
|
|
||
| for (int32_t iRow = 0; iRow < nRow; ++iRow) { | ||
| for (uint32_t iRow = 0; iRow < nRow; ++iRow) { |
There was a problem hiding this comment.
To fully resolve the signed/unsigned comparison and prevent potential overflow, the loop variable iRow should be of type uint64_t to match the type of nRow, which is declared as uint64_t on line 362. If nRow were to exceed the maximum value of a uint32_t, this loop would behave incorrectly.
for (uint64_t iRow = 0; iRow < nRow; ++iRow) {
Description
Issue(s)
https://project.feishu.cn/taosdata_td/defect/detail/6779910096
https://project.feishu.cn/taosdata_td/defect/detail/6779837756
https://project.feishu.cn/taosdata_td/defect/detail/6779880209
Checklist
Please check the items in the checklist if applicable.