-
Notifications
You must be signed in to change notification settings - Fork 124
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
Maybe unsound in c2str_vec #1776
Comments
Thanks for your suggestion, I will review this code |
As far as I know, derefer a null pointer in Rust will cause panic, not ub. But I think it is reasonable to change to pub(crate). If you have a better suggestion, thank you for any kind contribution. |
Thank you for your response! I appreciate your insights. However, I would like to clarify that dereferencing a null pointer in Rust does not cause a |
By the way, if you can confirm that all calls to
I hope this suggestion is helpful! |
Thanks for your advice. I did a simple test.
and i got I'm not very familiar with this, maybe I should learn more about this :) |
@He1pa Thank you for your trust! However, since I am completely unfamiliar with this project, I am concerned that submitting a PR might encounter various compilation issues or even negatively affect the functionality of the project. Therefore, I would like to propose two possible solutions, and you can choose the one that you find more suitable for addressing this issue. Solution 1: Mark the Function as unsafe and Add Documentation
Solution 2: Add Internal Checks to Ensure Pointer Validity
Comparison Solution 2 is safer, as the caller does not need to ensure the validity of the input pointer, and it provides explicit error messages (e.g., through panic) when encountering issues like null pointers. However, it comes at the cost of additional runtime checks. You can decide which solution to adopt based on the specific use cases of this function :) |
If you think option 2 is more appropriate, then I'm happy to submit a PR because it doesn't involve refactoring the code elsewhere. Haha. |
cc @zong-zhe what do you think about it? I prefer option 2 |
Oh, this is really cool! The second option is better. And we are actively seeking the community's support to help us build the KCL community together. If you, @lwz23, as a tech expert, are interested, you are more than welcome to submit a PR to help us add this part. We welcome you to join us as a contributor to KCL. Furthermore, we could invite you to become a community maintainer if opportunities arise. Thanks again for the feedback you provided for KCL; it has immensely benefited us. 👍👍👍 |
Thanks for your trust! I will submit a PR to fix this issue. And I am happy to contribue to KCL in the future. |
In the same rs file I found the following code:
It seems to me that there is also the possibility of a null pointer. Especially this part is very strange to me:
In Rust, it is generally expected that if a |
I have submitted a PR to address this issue. If you find anything that could be improved or adjusted, please feel free to either modify it directly in the PR or let me know your suggestions. |
cc @He1pa , we need to review at this PR together |
hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
Considering
pub mod api
and this is apub
function, I assume user can directly call to this function, if it's this case , I think there may exist a unsound problem in this code, eg. maybe ptr_array is null pointer? It will lead to UB. I suggest mark this function as unsafe or add additional check to varify the pointer. I chose to report this issue for security reasons, but please don't mind if the function is not intended for external use and should be marked as pub(crate), or if this is an error report and there is actually no unsound problem.The text was updated successfully, but these errors were encountered: