GCS_MAVLink: fixed null termination bug

found with ASAN
This commit is contained in:
Andrew Tridgell 2016-04-26 18:20:35 +10:00
parent 69e233a39d
commit 197e72acc0

View File

@ -1121,11 +1121,12 @@ void GCS_MAVLINK::send_ahrs(AP_AHRS &ahrs)
*/
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_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);
text[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN] = 0;
send_statustext(severity, mavlink_active, text);
}