Change sprintf to SNPRINTF in simulators

https://github.com/Hamlib/Hamlib/issues/857
pull/943/head
Mike Black W9MDB 2022-01-18 16:23:52 -06:00
rodzic 7ecd467126
commit f48654e199
2 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -6,6 +6,7 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <hamlib/rig.h>
#define BUFSIZE 256
@ -229,12 +230,12 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "FA;") == 0)
{
sprintf(buf, "FA%011d;", freqa);
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
write(fd, buf, strlen(buf));
}
else if (strcmp(buf, "FB;") == 0)
{
sprintf(buf, "FB%011d;", freqb);
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
write(fd, buf, strlen(buf));
}

Wyświetl plik

@ -6,6 +6,7 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <hamlib/rig.h>
#define BUFSIZE 256
@ -190,12 +191,12 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "FA;") == 0)
{
sprintf(buf, "FA%011d;", freqa);
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
write(fd, buf, strlen(buf));
}
else if (strcmp(buf, "FB;") == 0)
{
sprintf(buf, "FA%011d;", freqa);
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "FA", 2) == 0)
@ -208,17 +209,17 @@ int main(int argc, char *argv[])
}
else if (strncmp(buf, "AI;", 3) == 0)
{
sprintf(buf, "AI0;");
SNPRINTF(buf, sizeof(buf), "AI0;");
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "SA;", 3) == 0)
{
sprintf(buf, "SA0;");
SNPRINTF(buf, sizeof(buf), "SA0;");
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "MD;", 3) == 0)
{
sprintf(buf, "MD%d;", modeA); // not worried about modeB yet for simulator
SNPRINTF(buf, sizeof(buf), "MD%d;", modeA); // not worried about modeB yet for simulator
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "MD", 2) == 0)
@ -227,7 +228,7 @@ int main(int argc, char *argv[])
}
else if (strncmp(buf, "FL;", 3) == 0)
{
sprintf(buf, "FL%03d;", filternum);
SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "FL", 2) == 0)
@ -236,7 +237,7 @@ int main(int argc, char *argv[])
}
else if (strncmp(buf, "DA;", 3) == 0)
{
sprintf(buf, "DA%d;", datamode);
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "DA", 2) == 0)