Compare commits

...

2 Commits

Author SHA1 Message Date
Simon Ruderich a3928d0ad0 Fix compiler warnings
- passing argument 2 of 'crc_generate_key' discards ‘const’ qualifier;
  a bit ugly but signature of crc_generate_key() is wrong
- variable 'linearized_history' set but not used
- typedef is unused
- superfluous arguments to DEBUG_LOG() and fprintf()
- implicit declaration of function 'memset'
- unused arguments
2024-04-27 12:22:33 +02:00
Simon Ruderich b3ceb50b23 Fix one-byte buffer-overflow in layer1_rx_process() 2024-04-27 12:17:58 +02:00
5 changed files with 13 additions and 9 deletions

View File

@ -81,7 +81,7 @@ result_t packet_mod_set_data(packet_mod_ctx_t *ctx, const unsigned char *data, s
memcpy(ctx->pkt_bytes, data, length);
ctx->length = length;
ctx->raw_data_crc = crc_generate_key(PAYLOAD_CRC_SCHEME, data, length);
ctx->raw_data_crc = crc_generate_key(PAYLOAD_CRC_SCHEME, (unsigned char *)data, length);
ctx->raw_data_len = length;
ctx->state = DATA_RAW;

View File

@ -101,10 +101,10 @@ static bool acquire_preamble(layer1_rx_t *rx, const float complex sample, bool d
// BPSK symbols and therefore can be used during ramp-up and preamble.
if(freq_est_holdoff_samples == 0) { //freq_est_history_write_idx == FREQ_EST_L) {
float complex linearized_history[FREQ_EST_L];
for(size_t i = 0; i < FREQ_EST_L; i++) {
linearized_history[i] = freq_est_history[(i + freq_est_history_write_idx) % FREQ_EST_L];
}
//float complex linearized_history[FREQ_EST_L];
//for(size_t i = 0; i < FREQ_EST_L; i++) {
// linearized_history[i] = freq_est_history[(i + freq_est_history_write_idx) % FREQ_EST_L];
//}
float freq_est = freq_est_in_rampup(freq_est_history, FREQ_EST_L, NULL);
@ -148,7 +148,7 @@ static bool acquire_preamble(layer1_rx_t *rx, const float complex sample, bool d
}
typedef enum squelch_state_t {
enum squelch_state_t {
SQUELCH_CLOSED,
SQUELCH_OPEN,
SQUELCH_JUST_OPENED,
@ -331,7 +331,7 @@ result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t
header_enc, 8, sizeof(header_enc), &nsyms));
if(fec_decode(rx->hdr_fec, sizeof(header), header_enc, header) != LIQUID_OK) {
DEBUG_LOG("Header decoding failed!\n", rx->modcod);
DEBUG_LOG("Header decoding failed!\n");
rx->state = RX_STATE_ACQUISITION;
rx->callback(RX_EVT_HEADER_ERROR, NULL, 0);
break;
@ -415,7 +415,7 @@ result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t
if(symbol_counter == rx->payload_len_symbols) {
unsigned int nsyms;
unsigned char payload_enc[rx->payload_len_enc_bytes];
unsigned char payload[rx->payload_len_bytes];
unsigned char payload[rx->payload_len_bytes+1];
ERR_CHECK_LIQUID(liquid_repack_bytes(
symbols_int, modem_get_bps(rx->payload_demod), rx->payload_len_symbols,

View File

@ -164,7 +164,7 @@ result_t layer1_tx_finalize_burst(layer1_tx_t *tx)
// allocate a temporary buffer
float complex *tmp = malloc(sizeof(float complex) * tx->samples_used);
if(!tmp) {
fprintf(stderr, "Could not allocate buffer for TX frequency correction.\n", len, tx->samples_used);
fprintf(stderr, "Could not allocate buffer for TX frequency correction.\n");
return ERR_NO_MEM;
}

View File

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <liquid/liquid.h>

View File

@ -58,6 +58,9 @@ static result_t sdr_rf_to_baseband(nco_crcf nco, firdecim_crcf decim,
void cb_rx(rx_evt_t evt, uint8_t *packet_data, size_t packet_len)
{
(void)packet_data;
(void)packet_len;
switch(evt)
{
case RX_EVT_CHECKSUM_ERROR: