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

Fix decoding of truncated messages containing variable length arrays [AP-948] #1381

Merged
merged 1 commit into from
Nov 21, 2023
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
7 changes: 7 additions & 0 deletions c/src/v4/acquisition.c
Original file line number Diff line number Diff line change
@@ -822,6 +822,9 @@ s8 sbp_msg_acq_sv_profile_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,

bool sbp_msg_acq_sv_profile_decode_internal(sbp_decode_ctx_t *ctx,
sbp_msg_acq_sv_profile_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_ACQ_SV_PROFILE_ENCODED_LEN) != 0) {
return false;
}
msg->n_acq_sv_profile =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ACQ_SV_PROFILE_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_acq_sv_profile; i++) {
@@ -904,6 +907,10 @@ s8 sbp_msg_acq_sv_profile_dep_encode(uint8_t *buf, uint8_t len,

bool sbp_msg_acq_sv_profile_dep_decode_internal(
sbp_decode_ctx_t *ctx, sbp_msg_acq_sv_profile_dep_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_ACQ_SV_PROFILE_DEP_ENCODED_LEN) !=
0) {
return false;
}
msg->n_acq_sv_profile = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_ACQ_SV_PROFILE_DEP_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_acq_sv_profile; i++) {
6 changes: 6 additions & 0 deletions c/src/v4/file_io.c
Original file line number Diff line number Diff line change
@@ -257,6 +257,9 @@ bool sbp_msg_fileio_read_resp_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u32_decode(ctx, &msg->sequence)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_contents =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_contents; i++) {
@@ -1009,6 +1012,9 @@ bool sbp_msg_fileio_write_req_decode_internal(sbp_decode_ctx_t *ctx,
&msg->filename, SBP_MSG_FILEIO_WRITE_REQ_FILENAME_MAX, ctx)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_data = (uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_data; i++) {
if (!sbp_u8_decode(ctx, &msg->data[i])) {
3 changes: 3 additions & 0 deletions c/src/v4/flash.c
Original file line number Diff line number Diff line change
@@ -65,6 +65,9 @@ bool sbp_msg_flash_program_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u8_decode(ctx, &msg->addr_len)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->addr_len = (uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->addr_len; i++) {
if (!sbp_u8_decode(ctx, &msg->data[i])) {
15 changes: 15 additions & 0 deletions c/src/v4/integrity.c
Original file line number Diff line number Diff line change
@@ -435,6 +435,9 @@ bool sbp_msg_ssr_flag_satellites_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_faulty_sats)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_faulty_sats =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_faulty_sats; i++) {
@@ -564,6 +567,9 @@ bool sbp_msg_ssr_flag_tropo_grid_points_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_faulty_points)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U16) != 0) {
return false;
}
msg->n_faulty_points =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U16);
for (uint8_t i = 0; i < msg->n_faulty_points; i++) {
@@ -669,6 +675,9 @@ bool sbp_msg_ssr_flag_iono_grid_points_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_faulty_points)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U16) != 0) {
return false;
}
msg->n_faulty_points =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U16);
for (uint8_t i = 0; i < msg->n_faulty_points; i++) {
@@ -774,6 +783,9 @@ bool sbp_msg_ssr_flag_iono_tile_sat_los_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_faulty_los)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_SV_ID_ENCODED_LEN) != 0) {
return false;
}
msg->n_faulty_los =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_SV_ID_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_faulty_los; i++) {
@@ -886,6 +898,9 @@ bool sbp_msg_ssr_flag_iono_grid_point_sat_los_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_faulty_los)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_SV_ID_ENCODED_LEN) != 0) {
return false;
}
msg->n_faulty_los =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_SV_ID_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_faulty_los; i++) {
3 changes: 3 additions & 0 deletions c/src/v4/logging.c
Original file line number Diff line number Diff line change
@@ -208,6 +208,9 @@ bool sbp_msg_fwd_decode_internal(sbp_decode_ctx_t *ctx, sbp_msg_fwd_t *msg) {
if (!sbp_u8_decode(ctx, &msg->protocol)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_fwd_payload =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_fwd_payload; i++) {
23 changes: 23 additions & 0 deletions c/src/v4/observation.c
Original file line number Diff line number Diff line change
@@ -442,6 +442,10 @@ bool sbp_msg_obs_decode_internal(sbp_decode_ctx_t *ctx, sbp_msg_obs_t *msg) {
if (!sbp_observation_header_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_PACKED_OBS_CONTENT_ENCODED_LEN) !=
0) {
return false;
}
msg->n_obs = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_PACKED_OBS_CONTENT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_obs; i++) {
@@ -6486,6 +6490,10 @@ bool sbp_msg_obs_dep_a_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_observation_header_dep_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) %
SBP_PACKED_OBS_CONTENT_DEP_A_ENCODED_LEN) != 0) {
return false;
}
msg->n_obs = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_PACKED_OBS_CONTENT_DEP_A_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_obs; i++) {
@@ -6577,6 +6585,10 @@ bool sbp_msg_obs_dep_b_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_observation_header_dep_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) %
SBP_PACKED_OBS_CONTENT_DEP_B_ENCODED_LEN) != 0) {
return false;
}
msg->n_obs = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_PACKED_OBS_CONTENT_DEP_B_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_obs; i++) {
@@ -6668,6 +6680,10 @@ bool sbp_msg_obs_dep_c_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_observation_header_dep_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) %
SBP_PACKED_OBS_CONTENT_DEP_C_ENCODED_LEN) != 0) {
return false;
}
msg->n_obs = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_PACKED_OBS_CONTENT_DEP_C_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_obs; i++) {
@@ -8726,6 +8742,9 @@ s8 sbp_msg_sv_az_el_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,

bool sbp_msg_sv_az_el_decode_internal(sbp_decode_ctx_t *ctx,
sbp_msg_sv_az_el_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_SV_AZ_EL_ENCODED_LEN) != 0) {
return false;
}
msg->n_azel =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_SV_AZ_EL_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_azel; i++) {
@@ -8809,6 +8828,10 @@ bool sbp_msg_osr_decode_internal(sbp_decode_ctx_t *ctx, sbp_msg_osr_t *msg) {
if (!sbp_observation_header_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_PACKED_OSR_CONTENT_ENCODED_LEN) !=
0) {
return false;
}
msg->n_obs = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_PACKED_OSR_CONTENT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_obs; i++) {
12 changes: 12 additions & 0 deletions c/src/v4/piksi.c
Original file line number Diff line number Diff line change
@@ -2323,6 +2323,9 @@ s8 sbp_msg_network_bandwidth_usage_encode(

bool sbp_msg_network_bandwidth_usage_decode_internal(
sbp_decode_ctx_t *ctx, sbp_msg_network_bandwidth_usage_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_NETWORK_USAGE_ENCODED_LEN) != 0) {
return false;
}
msg->n_interfaces =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_NETWORK_USAGE_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_interfaces; i++) {
@@ -2418,6 +2421,9 @@ bool sbp_msg_cell_modem_status_decode_internal(
if (!sbp_float_decode(ctx, &msg->signal_error_rate)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_reserved =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_reserved; i++) {
@@ -2545,6 +2551,9 @@ bool sbp_msg_specan_dep_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_float_decode(ctx, &msg->amplitude_unit)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_amplitude_value =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_amplitude_value; i++) {
@@ -2691,6 +2700,9 @@ bool sbp_msg_specan_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_float_decode(ctx, &msg->amplitude_unit)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_amplitude_value =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_amplitude_value; i++) {
21 changes: 21 additions & 0 deletions c/src/v4/signing.c
Original file line number Diff line number Diff line change
@@ -261,6 +261,9 @@ bool sbp_msg_ecdsa_certificate_decode_internal(
if (!sbp_u8_decode(ctx, &msg->flags)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_certificate_bytes =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_certificate_bytes; i++) {
@@ -699,6 +702,9 @@ bool sbp_msg_ecdsa_signature_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_ecdsa_signature_decode_internal(ctx, &msg->signature)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_signed_messages =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_signed_messages; i++) {
@@ -855,6 +861,9 @@ bool sbp_msg_ecdsa_signature_dep_b_decode_internal(
return false;
}
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_signed_messages =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_signed_messages; i++) {
@@ -1014,6 +1023,9 @@ bool sbp_msg_ecdsa_signature_dep_a_decode_internal(
return false;
}
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_signed_messages =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_signed_messages; i++) {
@@ -1145,6 +1157,9 @@ bool sbp_msg_ed25519_certificate_dep_decode_internal(
return false;
}
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_certificate_bytes =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_certificate_bytes; i++) {
@@ -1262,6 +1277,9 @@ bool sbp_msg_ed25519_signature_dep_a_decode_internal(
return false;
}
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U32) != 0) {
return false;
}
msg->n_signed_messages =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U32);
for (uint8_t i = 0; i < msg->n_signed_messages; i++) {
@@ -1394,6 +1412,9 @@ bool sbp_msg_ed25519_signature_dep_b_decode_internal(
return false;
}
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U32) != 0) {
return false;
}
msg->n_signed_messages =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U32);
for (uint8_t i = 0; i < msg->n_signed_messages; i++) {
8 changes: 8 additions & 0 deletions c/src/v4/solution_meta.c
Original file line number Diff line number Diff line change
@@ -160,6 +160,10 @@ bool sbp_msg_soln_meta_dep_a_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u32_decode(ctx, &msg->last_used_gnss_vel_tow)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_SOLUTION_INPUT_TYPE_ENCODED_LEN) !=
0) {
return false;
}
msg->n_sol_in = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_SOLUTION_INPUT_TYPE_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_sol_in; i++) {
@@ -317,6 +321,10 @@ bool sbp_msg_soln_meta_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u32_decode(ctx, &msg->age_gnss)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_SOLUTION_INPUT_TYPE_ENCODED_LEN) !=
0) {
return false;
}
msg->n_sol_in = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_SOLUTION_INPUT_TYPE_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_sol_in; i++) {
47 changes: 47 additions & 0 deletions c/src/v4/ssr.c
Original file line number Diff line number Diff line change
@@ -1104,6 +1104,10 @@ bool sbp_msg_ssr_code_biases_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u8_decode(ctx, &msg->iod_ssr)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_CODE_BIASES_CONTENT_ENCODED_LEN) !=
0) {
return false;
}
msg->n_biases = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_CODE_BIASES_CONTENT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_biases; i++) {
@@ -1254,6 +1258,10 @@ bool sbp_msg_ssr_phase_biases_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_s8_decode(ctx, &msg->yaw_rate)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_PHASE_BIASES_CONTENT_ENCODED_LEN) !=
0) {
return false;
}
msg->n_biases = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_PHASE_BIASES_CONTENT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_biases; i++) {
@@ -1382,6 +1390,9 @@ bool sbp_msg_ssr_stec_correction_dep_decode_internal(
if (!sbp_stec_header_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_STEC_SAT_ELEMENT_ENCODED_LEN) != 0) {
return false;
}
msg->n_stec_sat_list = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_STEC_SAT_ELEMENT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_stec_sat_list; i++) {
@@ -1601,6 +1612,9 @@ bool sbp_msg_ssr_stec_correction_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_sats)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_STEC_SAT_ELEMENT_ENCODED_LEN) != 0) {
return false;
}
msg->n_sats = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_STEC_SAT_ELEMENT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_sats; i++) {
@@ -1728,6 +1742,9 @@ bool sbp_msg_ssr_gridded_correction_decode_internal(
ctx, &msg->tropo_delay_correction)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_STEC_RESIDUAL_ENCODED_LEN) != 0) {
return false;
}
msg->n_stec_residuals =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_STEC_RESIDUAL_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_stec_residuals; i++) {
@@ -2006,6 +2023,10 @@ bool sbp_msg_ssr_gridded_correction_bounds_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_sats)) {
return false;
}
if (((ctx->buf_len - ctx->offset) %
SBP_STEC_SAT_ELEMENT_INTEGRITY_ENCODED_LEN) != 0) {
return false;
}
msg->n_sats = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_STEC_SAT_ELEMENT_INTEGRITY_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_sats; i++) {
@@ -2805,6 +2826,9 @@ s8 sbp_msg_ssr_satellite_apc_dep_encode(

bool sbp_msg_ssr_satellite_apc_dep_decode_internal(
sbp_decode_ctx_t *ctx, sbp_msg_ssr_satellite_apc_dep_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_SATELLITE_APC_ENCODED_LEN) != 0) {
return false;
}
msg->n_apc =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_SATELLITE_APC_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_apc; i++) {
@@ -2912,6 +2936,9 @@ bool sbp_msg_ssr_satellite_apc_decode_internal(
if (!sbp_u8_decode(ctx, &msg->iod_ssr)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_SATELLITE_APC_ENCODED_LEN) != 0) {
return false;
}
msg->n_apc =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_SATELLITE_APC_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_apc; i++) {
@@ -3568,6 +3595,9 @@ bool sbp_msg_ssr_stec_correction_dep_a_decode_internal(
if (!sbp_stec_header_dep_a_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_STEC_SAT_ELEMENT_ENCODED_LEN) != 0) {
return false;
}
msg->n_stec_sat_list = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_STEC_SAT_ELEMENT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_stec_sat_list; i++) {
@@ -3678,6 +3708,10 @@ bool sbp_msg_ssr_gridded_correction_no_std_dep_a_decode_internal(
ctx, &msg->tropo_delay_correction)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_STEC_RESIDUAL_NO_STD_ENCODED_LEN) !=
0) {
return false;
}
msg->n_stec_residuals = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_STEC_RESIDUAL_NO_STD_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_stec_residuals; i++) {
@@ -3800,6 +3834,9 @@ bool sbp_msg_ssr_gridded_correction_dep_a_decode_internal(
ctx, &msg->tropo_delay_correction)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_STEC_RESIDUAL_ENCODED_LEN) != 0) {
return false;
}
msg->n_stec_residuals =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_STEC_RESIDUAL_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_stec_residuals; i++) {
@@ -3905,6 +3942,9 @@ bool sbp_msg_ssr_grid_definition_dep_a_decode_internal(
if (!sbp_grid_definition_header_dep_a_decode_internal(ctx, &msg->header)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_rle_list =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_rle_list; i++) {
@@ -4163,6 +4203,9 @@ bool sbp_msg_ssr_orbit_clock_bounds_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_sats)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ORBIT_CLOCK_BOUND_ENCODED_LEN) != 0) {
return false;
}
msg->n_sats = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_ORBIT_CLOCK_BOUND_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_sats; i++) {
@@ -4408,6 +4451,10 @@ bool sbp_msg_ssr_code_phase_biases_bounds_decode_internal(
if (!sbp_u8_decode(ctx, &msg->n_sats_signals)) {
return false;
}
if (((ctx->buf_len - ctx->offset) %
SBP_CODE_PHASE_BIASES_SAT_SIG_ENCODED_LEN) != 0) {
return false;
}
msg->n_sats_signals = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_CODE_PHASE_BIASES_SAT_SIG_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_sats_signals; i++) {
10 changes: 10 additions & 0 deletions c/src/v4/system.c
Original file line number Diff line number Diff line change
@@ -509,6 +509,9 @@ bool sbp_msg_status_report_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u32_decode(ctx, &msg->uptime)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_SUB_SYSTEM_REPORT_ENCODED_LEN) != 0) {
return false;
}
msg->n_status = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_SUB_SYSTEM_REPORT_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_status; i++) {
@@ -702,6 +705,10 @@ bool sbp_msg_status_journal_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u8_decode(ctx, &msg->sequence_descriptor)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_STATUS_JOURNAL_ITEM_ENCODED_LEN) !=
0) {
return false;
}
msg->n_journal = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_STATUS_JOURNAL_ITEM_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_journal; i++) {
@@ -1748,6 +1755,9 @@ bool sbp_msg_group_meta_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u8_decode(ctx, &msg->n_group_msgs)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U16) != 0) {
return false;
}
msg->n_group_msgs =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U16);
for (uint8_t i = 0; i < msg->n_group_msgs; i++) {
3 changes: 3 additions & 0 deletions c/src/v4/telemetry.c
Original file line number Diff line number Diff line change
@@ -212,6 +212,9 @@ bool sbp_msg_tel_sv_decode_internal(sbp_decode_ctx_t *ctx,
if (!sbp_u8_decode(ctx, &msg->origin_flags)) {
return false;
}
if (((ctx->buf_len - ctx->offset) % SBP_TELEMETRY_SV_ENCODED_LEN) != 0) {
return false;
}
msg->n_sv_tel =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_TELEMETRY_SV_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_sv_tel; i++) {
15 changes: 15 additions & 0 deletions c/src/v4/tracking.c
Original file line number Diff line number Diff line change
@@ -712,6 +712,10 @@ s8 sbp_msg_tracking_state_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,

bool sbp_msg_tracking_state_decode_internal(sbp_decode_ctx_t *ctx,
sbp_msg_tracking_state_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_TRACKING_CHANNEL_STATE_ENCODED_LEN) !=
0) {
return false;
}
msg->n_states = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_TRACKING_CHANNEL_STATE_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_states; i++) {
@@ -862,6 +866,9 @@ s8 sbp_msg_measurement_state_encode(uint8_t *buf, uint8_t len,

bool sbp_msg_measurement_state_decode_internal(
sbp_decode_ctx_t *ctx, sbp_msg_measurement_state_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_MEASUREMENT_STATE_ENCODED_LEN) != 0) {
return false;
}
msg->n_states = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_MEASUREMENT_STATE_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_states; i++) {
@@ -1478,6 +1485,10 @@ s8 sbp_msg_tracking_state_dep_a_encode(

bool sbp_msg_tracking_state_dep_a_decode_internal(
sbp_decode_ctx_t *ctx, sbp_msg_tracking_state_dep_a_t *msg) {
if (((ctx->buf_len - ctx->offset) %
SBP_TRACKING_CHANNEL_STATE_DEP_A_ENCODED_LEN) != 0) {
return false;
}
msg->n_states = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_TRACKING_CHANNEL_STATE_DEP_A_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_states; i++) {
@@ -1644,6 +1655,10 @@ s8 sbp_msg_tracking_state_dep_b_encode(

bool sbp_msg_tracking_state_dep_b_decode_internal(
sbp_decode_ctx_t *ctx, sbp_msg_tracking_state_dep_b_t *msg) {
if (((ctx->buf_len - ctx->offset) %
SBP_TRACKING_CHANNEL_STATE_DEP_B_ENCODED_LEN) != 0) {
return false;
}
msg->n_states = (uint8_t)((ctx->buf_len - ctx->offset) /
SBP_TRACKING_CHANNEL_STATE_DEP_B_ENCODED_LEN);
for (uint8_t i = 0; i < msg->n_states; i++) {
3 changes: 3 additions & 0 deletions c/src/v4/user.c
Original file line number Diff line number Diff line change
@@ -43,6 +43,9 @@ s8 sbp_msg_user_data_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,

bool sbp_msg_user_data_decode_internal(sbp_decode_ctx_t *ctx,
sbp_msg_user_data_t *msg) {
if (((ctx->buf_len - ctx->offset) % SBP_ENCODED_LEN_U8) != 0) {
return false;
}
msg->n_contents =
(uint8_t)((ctx->buf_len - ctx->offset) / SBP_ENCODED_LEN_U8);
for (uint8_t i = 0; i < msg->n_contents; i++) {
Original file line number Diff line number Diff line change
@@ -218,6 +218,9 @@ bool (((m.internal_decode_fn)))(sbp_decode_ctx_t *ctx, (((m.type_name))) *msg)
if (!(((f.decode_fn)))(ctx, &(((field)))[i])) { return false; }
}
((*- elif f.packing == "variable-array" *))
if ( ((ctx->buf_len - ctx->offset) % (((f.encoded_len_macro)))) != 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only change in need of review, everything else is generated

return false;
}
msg->(((f.size_fn))) = (uint8_t)((ctx->buf_len - ctx->offset) / (((f.encoded_len_macro))));
for (uint8_t i = 0; i < msg->(((f.size_fn))); i++) {
if (!(((f.decode_fn)))(ctx, &(((field)))[i])) { return false; }