annotate ffstools/caltools/fc-cal2bin.c @ 1011:6d9b10633f10 default tip

etmsync Pirelli IMEI retrieval: fix poor use of printf() Bug reported by Vadim Yanitskiy <fixeria@osmocom.org>: the construct where a static-allocated string was passed to printf() without any format arguments causes newer compilers to report a security problem. Given that formatted output is not needed here, just fixed string output, change printf() to fputs(), and direct the error message to stderr while at it.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 23 May 2024 17:29:57 +0000
parents 5bcf12be0834
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
292
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This utility converts an RF table from ASCII to binary format.
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/file.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 main(argc, argv)
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char **argv;
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 u_char buf[512];
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 unsigned size;
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int ofd;
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (argc != 3) {
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 fprintf(stderr,
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 "usage: %s ascii-input-file binary-output-file\n",
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 argv[0]);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 exit(1);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
466
5bcf12be0834 ffstools/caltools: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 292
diff changeset
24 if (read_rf_table_ext(argv[1], buf, 1, (char **) 0, &size))
292
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 exit(1);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 ofd = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0666);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (ofd < 0) {
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 perror(argv[2]);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 write(ofd, buf, size);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 close(ofd);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 exit(0);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }