llext: fix fixed-length name buffer usage
This was inspired by the detection of 2 instances of the warning:
warning: 'strncpy' specified bound 16 equals destination size
[-Wstringop-truncation]
The current code is already safe with regards to overflows, because
fixed-length string functions are used in the call tree. However, when
given a name 16 chars or larger, the current compare in llext_by_name()
will not work as expected because the stored extension name is truncated
to a max of 15.
Define a global LLEXT_MAX_NAME_LEN constant to simplify all this logic
and also implement name checks in the shell before calling llext_load().
Finally, using strlen() instead of strnlen() gets the real length of the
hex string passed as a parameter, which is important for the next safety
check.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
3 files changed