Skip to content
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

[Coverity CID: 220539] Improper use of negative value in tests/net/socket/misc/src/main.c #34002

Closed
zephyrbot opened this issue Apr 3, 2021 · 1 comment
Assignees
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/b86f7addae05add0db45d9b528854235fbb93a48/tests/net/socket/misc/src/main.c#L298

Category: Integer handling issues
Function: test_ipv4_so_bindtodevice
Component: Tests
CID: 220539

Details:

https://github.com/zephyrproject-rtos/zephyr/blob/b86f7addae05add0db45d9b528854235fbb93a48/tests/net/socket/misc/src/main.c

292         peer_addr.sin_family = AF_INET;
293         peer_addr.sin_port = htons(DST_PORT);
294         ret = inet_pton(AF_INET, CONFIG_NET_CONFIG_PEER_IPV4_ADDR,
295                 &peer_addr.sin_addr);
296         zassert_equal(ret, 1, "inet_pton failed");
297    
>>>     CID 220539:    (NEGATIVE_RETURNS)
>>>     "sock_s" is passed to a parameter that cannot be negative.
298         test_so_bindtodevice(sock_c, sock_s, (struct sockaddr *)&peer_addr,
299                      sizeof(peer_addr), (struct sockaddr *)&bind_addr,
300                      sizeof(bind_addr));
301     }
302    
303     void test_ipv6_so_bindtodevice(void)
292         peer_addr.sin_family = AF_INET;
293         peer_addr.sin_port = htons(DST_PORT);
294         ret = inet_pton(AF_INET, CONFIG_NET_CONFIG_PEER_IPV4_ADDR,
295                 &peer_addr.sin_addr);
296         zassert_equal(ret, 1, "inet_pton failed");
297    
>>>     CID 220539:    (NEGATIVE_RETURNS)
>>>     "sock_c" is passed to a parameter that cannot be negative.
298         test_so_bindtodevice(sock_c, sock_s, (struct sockaddr *)&peer_addr,
299                      sizeof(peer_addr), (struct sockaddr *)&bind_addr,
300                      sizeof(bind_addr));
301     }
302    
303     void test_ipv6_so_bindtodevice(void)

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v29271/p12996

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the CODEOWNERS file.

@zephyrbot zephyrbot added bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug labels Apr 3, 2021
@rlubos
Copy link
Contributor

rlubos commented Apr 7, 2021

It's a false-positive. sock_c/sock_s cannot be negative at this point as the test verifies this earlier and asserts in case of a negative value.

@rlubos rlubos closed this as completed Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

5 participants