-
Notifications
You must be signed in to change notification settings - Fork 12
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
replace atoi with strtol #6
Conversation
Signed-off-by: Mai Bui <maibui@microsoft.com>
/azp run sonic-net.sonic-dhcpmon |
Commenter does not have sufficient privileges for PR 6 in repo sonic-net/sonic-dhcpmon |
/azpw run sonic-net.sonic-dhcpmon |
/AzurePipelines run sonic-net.sonic-dhcpmon |
Commenter does not have sufficient privileges for PR 6 in repo sonic-net/sonic-dhcpmon |
@qiluo-msft @kellyyeh could you help review this PR? I don't have permission to add reviewers. |
src/main.cpp
Outdated
@@ -150,15 +150,15 @@ int main(int argc, char **argv) | |||
i++; | |||
break; | |||
case 's': | |||
snaplen = atoi(argv[i + 1]); | |||
snaplen = strtol(argv[i + 1], NULL, 10); |
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.
Signed-off-by: Mai Bui <maibui@microsoft.com>
Signed-off-by: Mai Bui <maibui@microsoft.com>
Signed-off-by: Mai Bui <maibui@microsoft.com>
Signed-off-by: Mai Bui <maibui@microsoft.com>
src/main.cpp
Outdated
@@ -116,9 +117,10 @@ int main(int argc, char **argv) | |||
int i; | |||
int window_interval = dhcpmon_default_health_check_window; | |||
int max_unhealthy_count = dhcpmon_default_unhealthy_max_count; | |||
size_t snaplen = dhcpmon_default_snaplen; | |||
int snaplen = dhcpmon_default_snaplen; |
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.
Sorry for misleading. Original types are good.
Signed-off-by: Mai Bui <maibui@microsoft.com>
Signed-off-by: Mai Bui <maibui@microsoft.com>
Signed-off-by: Mai Bui <maibui@microsoft.com>
@kellyyeh could you help review? |
/azp run |
/azp run sonic-net.sonic-dhcpmon |
/azp run sonic-net.sonic-dhcpmon |
Azure Pipelines successfully started running 1 pipeline(s). |
From Semgrep: https://semgrep.dev/r?q=c.lang.correctness.incorrect-use-ato-fn.incorrect-use-ato-fn
From atoi() man page: https://www.man7.org/linux/man-pages/man3/atoi.3.html
Therefore, replace atoi() with strtol()
Verified by kill dhcpmon process, installing new .deb change to dhcp_relay docker, execute dhcpmon process, check if counters is printing in syslog, compare counters before and after this change.
logs:
before.txt
after.txt
example commands:
command.txt