Skip to content

[swss] Replace memset functions#2423

Merged
maipbui merged 4 commits intosonic-net:masterfrom
maipbui:swss_replace_memset
Sep 14, 2022
Merged

[swss] Replace memset functions#2423
maipbui merged 4 commits intosonic-net:masterfrom
maipbui:swss_replace_memset

Conversation

@maipbui
Copy link
Contributor

@maipbui maipbui commented Aug 22, 2022

Signed-off-by: maipbui [email protected]

What I did
Replace memset() by memset_s()
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 verified it

Details if related

@maipbui maipbui requested a review from qiluo-msft August 22, 2022 19:47
@maipbui maipbui marked this pull request as ready for review September 14, 2022 13:38
@maipbui maipbui merged commit 05c5c2f into sonic-net:master Sep 14, 2022
@maipbui maipbui deleted the swss_replace_memset branch September 14, 2022 13:41
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
Signed-off-by: maipbui [email protected]
What I did
Replace memset() by memset_s()
Why I did it
memset() is an insecure function that can cause buffer overflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants