From 192822417b80e8ea7929c14ed2c1dfbf56cc511b Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 23 Oct 2023 09:33:32 -0500 Subject: [PATCH] Fix segfault for Kenwood L MICGAIN Fix potential segfault in iofunc.c when stopset is null --- rigs/kenwood/kenwood.c | 2 +- rigs/kenwood/kenwood.h | 2 +- simulators/simts590.c | 9 +++++++-- src/iofunc.c | 2 +- src/network.c | 4 +++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index b77d854a1..250a83840 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -2861,7 +2861,7 @@ static int kenwood_get_micgain_minmax(RIG *rig, int *micgain_now, if (retval != RIG_OK) { RETURNFUNC(retval); } retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf), - NULL, 0, 0, 1); + NULL, ";", 1, 1); rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval); diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index 4e7fdd5cd..174ed9364 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "idx_builtin.h" -#define BACKEND_VER "20231011" +#define BACKEND_VER "20231023" #define EOM_KEN ';' #define EOM_TH '\r' diff --git a/simulators/simts590.c b/simulators/simts590.c index 7a0cbf80a..978b982ef 100644 --- a/simulators/simts590.c +++ b/simulators/simts590.c @@ -32,6 +32,7 @@ int width_low = 0; int afgain = 50; int usb_af = 5; int usb_af_input = 2; +int mic_gain = 50; int getmyline(int fd, char *buf) @@ -153,8 +154,12 @@ int main(int argc, char *argv[]) else if (strcmp(buf, "MG;") == 0) { hl_usleep(mysleep * 1000); - pbuf = "MG050;"; - WRITE(fd, pbuf, strlen(pbuf)); + SNPRINTF(buf, sizeof(buf), "MG%03d;", mic_gain); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MG", 2) == 0) + { + sscanf(buf,"MG%d", &mic_gain); } else if (strcmp(buf, "AG0;") == 0) { diff --git a/src/iofunc.c b/src/iofunc.c index ea5c198ad..4d58694c4 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -1427,7 +1427,7 @@ static int read_string_generic(hamlib_port_t *p, // direct); } // special read for FLRig - if (strcmp(stopset, "") == 0) + if (stopset != NULL && strcmp(stopset, "") == 0) { if (strstr((char*)rxbuffer, stopset)) { diff --git a/src/network.c b/src/network.c index d694e4add..15b7fbe2c 100644 --- a/src/network.c +++ b/src/network.c @@ -515,6 +515,7 @@ static int multicast_publisher_write_data(multicast_publisher_args return (RIG_OK); } +#if 0 // disable until we figure out what to do about Windows poor performance static int multicast_publisher_read_data(multicast_publisher_args const *mcast_publisher_args, size_t length, unsigned char *data) { @@ -557,6 +558,7 @@ static int multicast_publisher_read_data(multicast_publisher_args return (RIG_OK); } +#endif #else @@ -978,6 +980,7 @@ void *multicast_publisher(void *arg) } for(i=0;i<5;++i) { + hl_usleep(200*1000); if (rig->state.cache.freqMainA != freqA) { freqA = rig->state.cache.freqMainA; @@ -1033,7 +1036,6 @@ void *multicast_publisher(void *arg) widthC = rig->state.cache.widthMainC; break; } - hl_usleep(200*1000); } }