diff options
author | Clayton Smith <argilo@gmail.com> | 2024-01-02 18:17:33 -0500 |
---|---|---|
committer | Jeff Long <willcode4@gmail.com> | 2024-01-05 13:02:49 -0500 |
commit | 5cf6867530b42387c5e44ba2aaac1642b326b987 (patch) | |
tree | cddcb24ecbd54ee19263f2fa1fcadf62b4b2a908 | |
parent | analog: Remove unused include (diff) | |
download | gnuradio-5cf6867530b42387c5e44ba2aaac1642b326b987.tar.xz gnuradio-5cf6867530b42387c5e44ba2aaac1642b326b987.zip |
fec: Fix input buffer overrun in polar encoder
Signed-off-by: Clayton Smith <argilo@gmail.com>
(cherry picked from commit 23e58b2894b541e174fc235d253cc424299a09bf)
Signed-off-by: Jeff Long <willcode4@gmail.com>
-rw-r--r-- | gr-fec/lib/polar_encoder.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gr-fec/lib/polar_encoder.cc b/gr-fec/lib/polar_encoder.cc index 84633ec89..465f0c968 100644 --- a/gr-fec/lib/polar_encoder.cc +++ b/gr-fec/lib/polar_encoder.cc @@ -132,17 +132,17 @@ void polar_encoder::insert_packed_frozen_bits_and_reverse( std::begin(d_frozen_bit_prototype), std::end(d_frozen_bit_prototype), target); const int* info_bit_reversed_positions_ptr = &d_info_bit_positions_reversed[0]; int bit_num = 0; - unsigned char byte = *input; + unsigned char byte; int bit_pos; while (bit_num < num_info_bits()) { + if (bit_num % 8 == 0) { + byte = *input; + ++input; + } bit_pos = *info_bit_reversed_positions_ptr++; insert_packet_bit_into_packed_array_at_position( target, byte, bit_pos, bit_num % 8); ++bit_num; - if (bit_num % 8 == 0) { - ++input; - byte = *input; - } } } |