Change sprint to SNPRINTF in rig.c

https://github.com/Hamlib/Hamlib/issues/857
pull/943/head
Mike Black W9MDB 2022-01-18 14:39:34 -06:00
rodzic 9e3afe2729
commit 165b5b2921
1 zmienionych plików z 6 dodań i 8 usunięć

Wyświetl plik

@ -6504,17 +6504,15 @@ int HAMLIB_API rig_get_rig_info(RIG *rig, char *response, int max_response_len)
txa = split == 0;
rxb = !rxa;
txb = split == 1;
snprintf(response, max_response_len,
"VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nVFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nSplit=%d SatMode=%d\nRig=%s\nApp=Hamlib\nVersion=20210506 1.0.0\nCRC=0x00000000\n",
SNPRINTF(response, max_response_len-strlen("CRC=0x00000000\n"),
"VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nVFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nSplit=%d SatMode=%d\nRig=%s\nApp=Hamlib\nVersion=20210506 1.0.0\n",
rig_strvfo(vfoA), freqA, modeAstr, (int)widthA, rxa, txa, rig_strvfo(vfoB),
freqB, modeBstr, (int)widthB, rxb, txb, split, satmode, rig->caps->model_name);
unsigned long crc = gen_crc((unsigned char *)response, strlen(response));
char *p = strstr(response, "CRC=");
if (p)
{
sprintf(p, "CRC=0x%08lx\n", crc);
}
char tmpstr[32];
SNPRINTF(tmpstr, sizeof(tmpstr), "CRC=0x%08lx\n", crc);
strcat(response,tmpstr);
if (strlen(response) >= max_response_len - 1)
{