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

Memory allocation failue check #1507

Open
pawszw2 opened this issue Aug 27, 2024 · 2 comments
Open

Memory allocation failue check #1507

pawszw2 opened this issue Aug 27, 2024 · 2 comments

Comments

@pawszw2
Copy link

pawszw2 commented Aug 27, 2024

Environment

  • Build System: [CMake]
  • Operating System: [Linux]
  • Operating System Version: [Ubuntu 22.04.4]
  • Hosted Environment: [NRF5340 - Zephyr]

libcoap Configuration Summary

Irrelevant

Problem Description

Hi!
When I was using libcoap with OSCORE, I run into a problem of unsuccessful encryption (server returned 4.01 Unauthorized). After some investigation I've found out that it was due to failed coap_malloc_type() and result of allocation not being checked against NULL. I think that NULL checks should be introduced after each coap_malloc_type() invocation.

Expected Behavior

Error log with information, that memory allocation failed, and 5.xx (probably 5.00) error code returned.

Actual Behavior

No information about failed allocation and wrong error code (4.01 suggesting an error on client's side).

Steps to reproduce

NULLchecks after allocation are missing in many places, so it requires many scenarios.

I also don't know if server returns 5.00 after memory allocation in places we check it.

Code to reproduce this issue

Debug Logs

Other items if possible

@mrdeep1
Copy link
Collaborator

mrdeep1 commented Aug 27, 2024

Thanks for raising this. It would be good to know which coap_malloc_type() failed for you (file and line no). In the OSCORE specific code, NULL returns are checked for (otherwise you will be seeing memory access errors), but they may be taking wrong decisions.

@mrdeep1
Copy link
Collaborator

mrdeep1 commented Nov 23, 2024

See #1546 updates to Zephyr to help track which coap_malloc_type() is failing for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants