Commit c8832617 authored by Robert Schmidt's avatar Robert Schmidt

Fix signed integer overflow in PSS search

Detected through UBSan
parent 8fbc15ba
......@@ -661,7 +661,6 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
{
unsigned int n, ar, peak_position, pss_source;
int64_t peak_value;
int64_t result;
int64_t avg[NUMBER_PSS_SEQUENCE]={0};
double ffo_est=0;
......@@ -704,11 +703,13 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
for (ar=0; ar<frame_parms->nb_antennas_rx; ar++) {
/* perform correlation of rx data and pss sequence ie it is a dot product */
result = dot_product64((short*)primary_synchro_time_nr[pss_index],
(short*)&(rxdata[ar][n+is*frame_parms->samples_per_frame]),
const int64_t result = dot_product64((short *)primary_synchro_time_nr[pss_index],
(short *)&(rxdata[ar][n + is * frame_parms->samples_per_frame]),
frame_parms->ofdm_symbol_size,
shift);
pss_corr_ue += squaredMod(*(c32_t*)&result);
const c32_t r32 = *(c32_t*)&result;
const c64_t r64 = {.r = r32.r, .i = r32.i};
pss_corr_ue += squaredMod(r64);
//((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0]; /* real part */
//((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */
//((short*)&synchro_out)[0] += ((int*) &result)[0]; /* real part */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment