Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jukkar
AFAICT
status->ssid
is 32 bytes. currently this change givesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually in my previous submission, it was [WIFI_SSID_MAX_LEN-1]. But it seems the auditors had issues with it, so I changed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it should be
[WIFI_SSID_MAX_LEN - 1]
.@jukkar @krish2718 should we change the API from
char ssid[WIFI_SSID_MAX_LEN];
tochar ssid[WIFI_SSID_MAX_LEN + 1];
as a proper solution instead?https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/net/wifi_mgmt.h#L432
https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/net/wifi_mgmt.h#L432
If yes, I suggest closing this PR and opening another with that solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is correct. If we want to store null at the end, there needs to be space for it in the buffer (so +1 is needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to change it to WIFI_SSID_MAX_LEN-1. Instead of changing the definition, because WIFI_SSID_MAX_LEN already indicates the maximum length. If you +1 to the maximum length, it will make the code extremely difficult to understand.
Edit:
And, in the example I gave, we should keep in sync with him instead of changing the definition at will.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard for SSID is 32 bytes long. The way it is now, it will only be 31 bytes due to the
'\0'
so it must be increased if we want null termination and 32 bytes.I am surprised this change passed CI, the warning gets created without the CONFIG_SPEED_OPTIMIZATIONS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's okay, I'll reopen a PR tomorrow. It'll change the size of the ssid member (even though I’m not a big fan of this, but if the ssid is the standard 32-byte length, then the ssid member has to be 33 bytes).