-
Notifications
You must be signed in to change notification settings - Fork 278
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
[sairedis] Replace memset functions #1110
base: master
Are you sure you want to change the base?
Conversation
can we use memset_s in all places instead doing ifdef ? |
e343fdd
to
9040fc9
Compare
Signed-off-by: maipbui <maibui@microsoft.com>
2d0aa51
to
af946f8
Compare
I don't think so, seems like gcc/g++ doesn't support memset_s |
Signed-off-by: maipbui <maibui@microsoft.com>
Signed-off-by: maipbui <maibui@microsoft.com>
Signed-off-by: maipbui <maibui@microsoft.com>
Signed-off-by: maipbui <maibui@microsoft.com>
/AzurePipelines run Azure.sonic-sairedis |
Azure Pipelines successfully started running 1 pipeline(s). |
@kcudnik Could you review again? |
please satisfy code coverage: https://dev.azure.com/mssonic/build/_build/results?buildId=147452&view=codecoverage-tab in unittests |
i added some unittest to cover old code #1133 |
Signed-off-by: maipbui maibui@microsoft.com
Why I did it
memset()
is an insecure function that can cause buffer overflow.memset()
may not be called by the compiler. Due to compiler optimization: an optimizing compiler, which identifies and removes the function that overwrites the contents as a dead store because the memory is not used subsequently. If sensitive data is in memory, it's dangerous if compiler optimization happens.Ref:
https://cwe.mitre.org/data/definitions/14.html
https://registry.semgrep.dev/rule/c.lang.security.insecure-use-memset.insecure-use-memset
How I did it
Remove
memset()
, initialize the variable to 0.