mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-29 05:24:18 -04:00
d44a953cfa
Change the ft8_crc message length parameter from signed int to uint32_t
since it represents a non-negative FT8 message bit count.
GCC reported a potential buffer overflow in the memcpy() call:
warning: ‘__builtin_memcpy’ specified bound between
18446744073709551560 and 18446744073709551564 exceeds maximum object size
[-Wstringop-overflow=]
The warning was caused by the signed message length allowing negative
values to be converted into a very large unsigned size when calculating
the memcpy() byte count.
Using an unsigned fixed-width type better represents the valid range of
the FT8 message length and prevents invalid negative lengths from being
interpreted as extremely large memory operations.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
44 lines
2.3 KiB
C++
44 lines
2.3 KiB
C++
///////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
// written by Christian Daniel //
|
|
// Copyright (C) 2015-2019, 2023 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
// //
|
|
// This is the code from ft8mon: https://github.com/rtmrtmrtmrtm/ft8mon //
|
|
// reformatted and adapted to Qt and SDRangel context //
|
|
// //
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
// it under the terms of the GNU General Public License as published by //
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
// (at your option) any later version. //
|
|
// //
|
|
// This program is distributed in the hope that it will be useful, //
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
// GNU General Public License V3 for more details. //
|
|
// //
|
|
// You should have received a copy of the GNU General Public License //
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
#ifndef libldpc_h
|
|
#define libldpc_h
|
|
|
|
#include <cstdint>
|
|
|
|
namespace FT8 {
|
|
|
|
class LDPC {
|
|
public:
|
|
static void ldpc_decode(const float llcodeword[], int iters, int plain[], int *ok);
|
|
static void ldpc_decode_log(float codeword[], int iters, int plain[], int *ok);
|
|
static void ft8_crc(int msg1[], uint32_t msglen, int out[14]);
|
|
static void gauss_jordan(int rows, int cols, int m[174][2 * 91], int which[91], int *ok);
|
|
|
|
private:
|
|
static int ldpc_check(int codeword[]);
|
|
static float fast_tanh(float x);
|
|
};
|
|
|
|
} // namespace FT8
|
|
|
|
#endif // libldpc_h
|