-
Notifications
You must be signed in to change notification settings - Fork 312
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(asan): global-buffer-overflow in function escape_sds_argv of data_operations.cpp #509
Conversation
|
About passing NULL for 'init', it has a rule |
Yeah, I know, so I test |
No, I think it is that we use it mistake. |
So You don't have to worry about resolution 2(”NULL“) whether to cause other problem. |
in latest commit, I choose resolution 2 |
…_operations.cpp (#509) Co-authored-by: HuangWei <[email protected]> Co-authored-by: Wu Tao <[email protected]>
What problem does this PR solve?
Coredump
Related Code
https://github.com/XiaoMi/pegasus/blob/51f868f031fed9b8fbff7aa0d0e601176944523b/src/shell/commands/data_operations.cpp#L2429-L2438
Reason
The problem at line 2433:
https://github.com/XiaoMi/pegasus/blob/51f868f031fed9b8fbff7aa0d0e601176944523b/src/shell/commands/data_operations.cpp#L2433
When pass
“”
(empty string),sdsnewlen
will excute the code:https://github.com/XiaoMi/pegasus/blob/51f868f031fed9b8fbff7aa0d0e601176944523b/src/shell/sds/sds.c#L134-L136
because the
initlen
> length ofinit
(also is ""), it will core.The problem will happen on all functions which use the
escape_sds_argv
What is changed and how it works?
Actually, it has two resolutions:
initlen
(also thedest_len
)NULL
to skipmemcpy(s, init, initlen)
and directly exectes[initlen] = '\0'
I have test the two resolutions and it work well, but I'm not sure that pass
NULL
(resolution 2) whether to cause other problem.Check List
Related changes