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

samples: net: mdns_responder: fix coverity issues #33162

Merged
merged 2 commits into from
Mar 9, 2021
Merged

samples: net: mdns_responder: fix coverity issues #33162

merged 2 commits into from
Mar 9, 2021

Conversation

gudnimg
Copy link
Contributor

@gudnimg gudnimg commented Mar 8, 2021

samples/net/mdns_responder/src/service.c Outdated Show resolved Hide resolved
samples/net/mdns_responder/src/service.c Show resolved Hide resolved
samples/net/mdns_responder/src/service.c Outdated Show resolved Hide resolved
samples/net/mdns_responder/src/service.c Outdated Show resolved Hide resolved
Check return value if sendto() fails.

Coverity-CID: 215391
Fixes #33093

Signed-off-by: Guðni Már Gilbert <[email protected]>
Avoid resource leak by closing socket when there is an error.

Coverity-CID: 215381
Fixes #33094

Signed-off-by: Guðni Már Gilbert <[email protected]>
@gudnimg gudnimg requested a review from jukkar March 9, 2021 10:31
welcome(client_fd);
r = welcome(client_fd);
if (r == -1) {
NET_DBG("send() failed (%d)", errno);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this should be NET_ERR().

Copy link
Contributor Author

@gudnimg gudnimg Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pfalcon Should I also add NET_ERR() when bind(), listen() and socket() fail? They seem to be equally fatal errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I don't know. If you used NET_DBG here because it's used in other similar places in this sample, that's ok. Or can just use NET_ERR here regardless (I'd do that ;-) ). I'm definitely not calling for scope creep in changes ;-).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I used NET_DBG() since it's used everywhere else. The main focus is to fix the coverity issue where the return value was not checked. I could add a separate commit to change NET_DBG() to NET_ERR() on top of the current changes.

@jukkar @tbursztyka what are your thoughts on the matter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main focus is to fix the coverity issue

Right, I remember that, and why I say I don't want to introduce more scope creep into that. LGTM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use NET_DBG() here, and if you want, you can send a separate PR later to change those to NET_ERR().

Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes!

@jukkar jukkar merged commit 6c3674c into zephyrproject-rtos:master Mar 9, 2021
@gudnimg gudnimg deleted the gudni-service-fix branch March 24, 2021 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants