mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 14:48:54 +08:00
use memcpy instead of strncpy
This commit is contained in:
committed by
Julian Oes
parent
a0bf7425ae
commit
12687f7d8f
@@ -422,11 +422,14 @@ protected:
|
||||
|
||||
while ((text_size = strlen(text)) > 0) {
|
||||
unsigned chunk_size = math::min(text_size, max_chunk_size);
|
||||
strncpy(msg.text, text, chunk_size);
|
||||
|
||||
// pad with zeros
|
||||
if (chunk_size < max_chunk_size) {
|
||||
memcpy(&msg.text[0], &text[0], chunk_size + 1);
|
||||
// pad with zeros
|
||||
memset(&msg.text + chunk_size, 0, max_chunk_size - chunk_size);
|
||||
|
||||
} else {
|
||||
memcpy(&msg.text[0], &text[0], chunk_size);
|
||||
}
|
||||
|
||||
mavlink_msg_statustext_send_struct(_mavlink->get_channel(), &msg);
|
||||
|
||||
Reference in New Issue
Block a user