mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 15:53:56 -04:00
GCS_MAVLink: fixed null termination bug
found with ASAN
This commit is contained in:
parent
69e233a39d
commit
197e72acc0
@ -1121,11 +1121,12 @@ void GCS_MAVLINK::send_ahrs(AP_AHRS &ahrs)
|
|||||||
*/
|
*/
|
||||||
void GCS_MAVLINK::send_statustext_all(MAV_SEVERITY severity, const char *fmt, ...)
|
void GCS_MAVLINK::send_statustext_all(MAV_SEVERITY severity, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char text[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN] {};
|
char text[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN+1] {};
|
||||||
va_list arg_list;
|
va_list arg_list;
|
||||||
va_start(arg_list, fmt);
|
va_start(arg_list, fmt);
|
||||||
hal.util->vsnprintf((char *)text, sizeof(text), fmt, arg_list);
|
hal.util->vsnprintf((char *)text, sizeof(text)-1, fmt, arg_list);
|
||||||
va_end(arg_list);
|
va_end(arg_list);
|
||||||
|
text[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN] = 0;
|
||||||
send_statustext(severity, mavlink_active, text);
|
send_statustext(severity, mavlink_active, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user