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 :207985] Argument cannot be negative in subsys/net/lib/websocket/websocket.c #22430

Closed
zephyrbot opened this issue Feb 3, 2020 · 2 comments
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: medium Medium impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/a3e89e84a801d9bc048b0ee2177f0fb11d1a925a/subsys/net/lib/websocket/websocket.c#L789

Category: Memory - corruptions
Function: websocket_recv_msg
Component: Networking
CID: 207985

Details:

697     #else
698             ret = recv(ctx->real_sock, &ctx->tmp_buf[ctx->tmp_buf_pos],
699                    ctx->tmp_buf_len - ctx->tmp_buf_pos,
700                    timeout == K_NO_WAIT ? MSG_DONTWAIT : 0);
701     #endif /* CONFIG_NET_TEST */
702    
>>>     CID 207985:    (REVERSE_NEGATIVE)
>>>     You might be using variable "ret" before verifying that it is >= 0.
703             if (ret < 0) {
704                 return -errno;
705             }
706    
707             if (ret == 0) {
708                 /* Socket closed */
783             ret = input_len;
784     #else
785             ret = recv(ctx->real_sock, ctx->tmp_buf, ctx->tmp_buf_len,
786                    timeout == K_NO_WAIT ? MSG_DONTWAIT : 0);
787     #endif /* CONFIG_NET_TEST */
788    
>>>     CID 207985:    (REVERSE_NEGATIVE)
>>>     You might be using variable "ret" before verifying that it is >= 0.
789             if (ret < 0) {
790                 return -errno;
791             }
792    
793             if (ret == 0) {
794                 return 0;

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v32951/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: medium Medium impact/importance bug labels Feb 3, 2020
@jenmwms jenmwms self-assigned this Feb 5, 2020
@jukkar
Copy link
Member

jukkar commented Feb 12, 2020

False positive, Coverity gets confused by various #ifdefs

@jukkar jukkar closed this as completed Feb 12, 2020
@jenmwms
Copy link
Collaborator

jenmwms commented Feb 13, 2020

@jukkar Thanks for looking into this and offering rationale. It helps me learn!

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: medium Medium impact/importance bug
Projects
None yet
Development

No branches or pull requests

5 participants