tests: cloud: Use strnlen() for ssafety#119
Conversation
Use strnlen() instead of strlen(). It was safe in this case, but always nice to use strnlen() when possible. Flagged by Sonarcloud. Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
There was a problem hiding this comment.
🎯 Core Changes: The primary change in this PR is the replacement of strlen() with strnlen() in the test file cloud_module_test.c. This change enhances safety by preventing potential buffer overflows when determining the length of strings. Additionally, a preprocessor directive is added to ensure strnlen() is available when compiling with -std=c99.
Verdict: Approve. The changes are straightforward, improve safety, and are unlikely to introduce any issues.
Code review performed by OPENAI - gpt-4o.
|



Use strnlen() instead of strlen(). It was safe in this case, but always nice to use strnlen() when possible.
Flagged by Sonarcloud.