You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
drivers: gnss: Fix snprintk return value check in gnss_dump
The snprintk function returns the number of characters that *would have
been* written if the buffer was large enough. This means if the return
value `ret` is greater than or equal to the buffer size `strsize`, the
output was truncated.
The existing check `(strsize < ret)` was incorrect as it did not
handle the case where `ret == strsize` (output fits exactly, but no
room for null terminator) and did not check for negative return values
which indicate an encoding error.
This commit corrects the check to `(ret < 0 || ret >= strsize)` to
properly detect truncation and errors, returning -ENOMEM in these
cases. This fix is applied to `gnss_dump_nav_data`, `gnss_dump_time`,
and `gnss_dump_satellite` functions.
Signed-off-by: Badr Bacem KAABIA <badrbacemkaabia@gmail.com>
0 commit comments