diff options
author | m-ri@users.noreply.github.com <m-ri@users.noreply.github.com> | 2015-05-18 22:36:31 +0200 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2015-06-17 14:59:45 -0400 |
commit | 2713a1e0f90c9e34ae7133fc672149a44ff26a9f (patch) | |
tree | a7e6a93aa90422c11919bd083682c3a35eb2e34c | |
parent | d4f3820e0049153b4c4d21067ae633f82291a8f9 (diff) |
Removed a potential buffer overflow in correlate_and_sync_cc_impl.cc
-rw-r--r-- | gr-digital/lib/correlate_and_sync_cc_impl.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gr-digital/lib/correlate_and_sync_cc_impl.cc b/gr-digital/lib/correlate_and_sync_cc_impl.cc index 80aee56d33..b8c8e8669d 100644 --- a/gr-digital/lib/correlate_and_sync_cc_impl.cc +++ b/gr-digital/lib/correlate_and_sync_cc_impl.cc @@ -120,11 +120,13 @@ namespace gr { d_filter->filter(noutput_items, in, corr); // Find the magnitude squared of the correlation - std::vector<float> corr_mag(noutput_items); + std::vector<float> corr_mag(noutput_items+1); volk_32fc_magnitude_squared_32f(&corr_mag[0], corr, noutput_items); + // Avoid buffer overflow from nested while, putting a stopper at the end + corr_mag[noutput_items]=0; int i = d_sps; - while(i < noutput_items) { + while(i < (noutput_items-1)) { if((corr_mag[i] - corr_mag[i-d_sps]) > d_thresh) { while(corr_mag[i] < corr_mag[i+1]) i++; |