Fix segfault for Kenwood L MICGAIN

Fix potential segfault in iofunc.c when stopset is null
pull/1410/head
Mike Black W9MDB 2023-10-23 09:33:32 -05:00
rodzic e0fa354d3a
commit 192822417b
5 zmienionych plików z 13 dodań i 6 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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'

Wyświetl plik

@ -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)
{

Wyświetl plik

@ -1427,7 +1427,7 @@ static int read_string_generic(hamlib_port_t *p,
// direct);
}
// special read for FLRig
if (strcmp(stopset, "</methodResponse>") == 0)
if (stopset != NULL && strcmp(stopset, "</methodResponse>") == 0)
{
if (strstr((char*)rxbuffer, stopset))
{

Wyświetl plik

@ -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);
}
}