Add check for -s switch on all utils to ensure integer is entered

pull/345/head
Michael Black W9MDB 2020-07-01 08:52:44 -05:00
rodzic c332036efe
commit f454cff0b7
11 zmienionych plików z 73 dodań i 13 usunięć

Wyświetl plik

@ -142,6 +142,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc,
argv,
@ -191,7 +192,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -185,6 +185,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
@ -230,7 +231,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -158,6 +158,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc,
argv,
@ -353,7 +354,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -4085,9 +4085,9 @@ declare_proto_rig(dump_state)
// backward compatible as new values will just generate warnings
if (chk_vfo_executed) // for 3.3 compatiblility
{
fprintf(fout, "vfo_ops=0x%x\n", rig->caps->vfo_ops);
fprintf(fout, "ptt_type=0x%x\n", rig->state.pttport.type.ptt);
fprintf(fout, "done\n");
fprintf(fout, "vfo_ops=0x%x\n", rig->caps->vfo_ops);
fprintf(fout, "ptt_type=0x%x\n", rig->state.pttport.type.ptt);
fprintf(fout, "done\n");
}
#if 0 // why isn't this implemented? Does anybody care?

Wyświetl plik

@ -227,6 +227,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc,
argv,
@ -393,7 +394,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'S':

Wyświetl plik

@ -265,6 +265,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc,
argv,
@ -442,7 +443,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -115,6 +115,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
@ -170,7 +171,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -99,6 +99,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
@ -154,7 +155,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -89,6 +89,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
@ -144,7 +145,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -147,6 +147,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc,
argv,
@ -196,7 +197,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':

Wyświetl plik

@ -179,6 +179,7 @@ int main(int argc, char *argv[])
{
int c;
int option_index = 0;
char dummy[2];
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
@ -224,7 +225,12 @@ int main(int argc, char *argv[])
exit(1);
}
serial_rate = atoi(optarg);
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
{
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
exit(1);
}
break;
case 'C':