Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_AIS: remove incorrect use of strncat #29171

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions libraries/AP_AIS/AP_AIS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <GCS_MAVLink/GCS_MAVLink.h>
#include <GCS_MAVLink/GCS.h>
#include <AP_AHRS/AP_AHRS.h>
#include <AP_Common/ExpandingString.h>

const AP_Param::GroupInfo AP_AIS::var_info[] = {

Expand Down Expand Up @@ -177,14 +178,14 @@ void AP_AIS::update()
}

// combine packets
char multi[AIVDM_PAYLOAD_SIZE*_incoming.total];
strncpy(multi,_AIVDM_buffer[msg_parts[0]].payload,AIVDM_PAYLOAD_SIZE);
ExpandingString s;
s.append(_AIVDM_buffer[msg_parts[0]].payload, strlen(_AIVDM_buffer[msg_parts[0]].payload));
for (uint8_t i = 1; i < _incoming.total - 1; i++) {
strncat(multi,_AIVDM_buffer[msg_parts[i]].payload,sizeof(multi));
s.append(_AIVDM_buffer[msg_parts[i]].payload, strlen(_AIVDM_buffer[msg_parts[i]].payload));
}
strncat(multi,_incoming.payload,sizeof(multi));
s.append(_incoming.payload, strlen(_incoming.payload));
#if HAL_LOGGING_ENABLED
const bool decoded = payload_decode(multi);
const bool decoded = payload_decode(s.get_string());
#endif
for (uint8_t i = 0; i < _incoming.total; i++) {
#if HAL_LOGGING_ENABLED
Expand Down
Loading