-
Notifications
You must be signed in to change notification settings - Fork 264
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 minor issue found during static code scan #740
Fix minor issue found during static code scan #740
Conversation
Fix using uninitialized value when calling Compare on unit tests. Fix Overrunning array of 16 bytes at byte offset 16 by dereferencing pointer ipa.ip_addr.ipv6_addr + mid + 1 on this case we call memset with a pointer to outside the block. This shouldn't cause any issues due to the fact that we call it with size to be written 0, but still should not be done.
@prsunny @qiluo-msft would you please merge this PR? |
common/ipprefix.h
Outdated
@@ -76,7 +76,8 @@ class IpPrefix | |||
{ | |||
assert(mid >= 0 && mid < 16); | |||
ipa.ip_addr.ipv6_addr[mid] = (uint8_t)(0xFF << (8 - bits)); | |||
memset(ipa.ip_addr.ipv6_addr + mid + 1, 0, 16 - mid - 1); | |||
if (mid < 15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qiluo-msft I replied in an email I sent you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error does not make sense, it indicates the limitation of scanner/linter you are using.
I suggest not to sacrifice code concision to workaround scanner’s issue. If you like, you can add a code comment to suppress scanner negative alarm.
@qiluo-msft any further comments or can we merge this one? |
/easycla |
/azpw run |
/AzurePipelines run |
No commit pushedDate could be found for PR 740 in repo sonic-net/sonic-swss-common |
/azpw run Azure.sonic-swss-common |
/AzurePipelines run Azure.sonic-swss-common |
No commit pushedDate could be found for PR 740 in repo sonic-net/sonic-swss-common |
Fix issue of using uninitialized value on unit tests.
Fix issue of using uninitialized value on unit tests.