Commit d00e42a5 authored by Titouan Soulard's avatar Titouan Soulard

trx-bridge: avoid buffer overflow

parent 70d99196
......@@ -5,6 +5,11 @@
#include <unistd.h>
#include "amarisoft/trx_driver.h"
#include "common/circular_buffer.h"
#include "common/hashtable.h"
#include "libpotoml/toml.h"
// Size of TRX buffer in IQ samples (complex)
#define TRX_BUFFER_SIZE 8192
#define SAMPLE_RATE_KHZ 30720
#include "trx-bridge/bridge.h"
// Size of TRX buffer in IQ samples (complex)
#define TRX_BUFFER_SIZE 4096
#define SAMPLE_RATE_KHZ 30720
char *bridge_trx_input_get_param_string(void *app_opaque, const char *prop_name) {
return potoml_toml_get_string((struct PotomlTomlSubset *) app_opaque, prop_name);
}
......@@ -327,7 +323,8 @@ int main(int argc, char *argv[]) {
if(output_read_count > 0) input_trx_state.trx_write_func2(&input_trx_state, input_tx_ts, (const void **) output_channels, output_read_count, 0, &write_md);
// Reading from input decrease the sample count to be read on next iteration
input_read_count = input_trx_state.trx_read_func2(&input_trx_state, &input_rx_ts, (void **) input_channels, input_max_read_count, 0, &read_md);
input_read_count = MIN(TRX_BUFFER_SIZE, input_max_read_count);
input_read_count = input_trx_state.trx_read_func2(&input_trx_state, &input_rx_ts, (void **) input_channels, input_read_count, 0, &read_md);
input_max_read_count -= input_read_count;
// Same timestamp handling as for output
......
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