nbiot_sync: fix potential segfault during sync when time gap is too big

master
Andre Puschmann 5 years ago
parent 3f99e40159
commit 2c6a95c1d5

@ -79,11 +79,11 @@ free_and_exit:
return ret; return ret;
} }
int srslte_rf_recv_wrapper_cs(void* h, cf_t* data[SRSLTE_MAX_CHANNELS], uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper_cs(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ---- \n", nsamples);
void* ptr[SRSLTE_MAX_CHANNELS]; void* ptr[SRSLTE_MAX_CHANNELS] = {};
for (int i = 0; i < SRSLTE_MAX_CHANNELS; i++) { for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
ptr[i] = data[i]; ptr[i] = data[i];
} }
return srslte_rf_recv_with_time_multi(h, ptr, nsamples, 1, NULL, NULL); return srslte_rf_recv_with_time_multi(h, ptr, nsamples, 1, NULL, NULL);

@ -483,6 +483,9 @@ static int receive_samples(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_
ptr[i] = &input_buffer[i][q->next_rf_sample_offset]; ptr[i] = &input_buffer[i][q->next_rf_sample_offset];
} }
// assure next_rf_sample_offset isn't larger than frame_len
q->next_rf_sample_offset = SRSLTE_MIN(q->next_rf_sample_offset, q->frame_len);
if (q->recv_callback(q->stream, ptr, q->frame_len - q->next_rf_sample_offset, &q->last_timestamp) < 0) { if (q->recv_callback(q->stream, ptr, q->frame_len - q->next_rf_sample_offset, &q->last_timestamp) < 0) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

Loading…
Cancel
Save