blob: 0c01ed03833720ea3b04bbc4b73a184ccda86581 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001stat: Fixing security formatting issues
2
3Fix security formatting issues related to printf without NULL argument
4
5stat.c: In function 'print_human_access':
6stat.c:292:13: error: format not a string literal and no format arguments [-Werror=format-security]
7 printf (access);
8 ^
9stat.c: In function 'print_human_time':
10stat.c:299:57: error: format not a string literal and no format arguments [-Werror=format-security]
11 if (strftime(str, 40, "%c", localtime(t)) > 0) printf(str);
12 ^
13stat.c: In function 'print_it':
14stat.c:613:6: error: format not a string literal and no format arguments [-Werror=format-security]
15 printf(b);
16 ^
17stat.c:642:6: error: format not a string literal and no format arguments [-Werror=format-security]
18 printf(b);
19 ^
20
21[YOCTO #9550]
22[https://bugzilla.yoctoproject.org/show_bug.cgi?id=9550]
23
24Upstream-Status: Pending
25
26Signed-off-by: Edwin Plauchu <edwin.plauchu.camacho@intel.com>
27
28diff --git a/stat.c b/stat.c
29index 1ed07a9..2be6f62 100644
30--- a/stat.c
31+++ b/stat.c
32@@ -289,15 +289,15 @@ void print_human_access(struct stat *statbuf)
33 default:
34 access[0] = '?';
35 }
36- printf (access);
37+ fputs(access,stdout);
38 }
39
40 void print_human_time(time_t *t)
41 {
42 char str[40];
43
44- if (strftime(str, 40, "%c", localtime(t)) > 0) printf(str);
45- else printf("Cannot calculate human readable time, sorry");
46+ if (strftime(str, 40, "%c", localtime(t)) > 0) fputs(str,stdout);
47+ else fputs("Cannot calculate human readable time, sorry",stdout);
48 }
49
50 /* print statfs info */
51@@ -610,7 +610,7 @@ void print_it(char *masterformat, char *filename,
52 {
53 strcpy (pformat, "%");
54 *m++ = '\0';
55- printf(b);
56+ fputs(b,stdout);
57
58 /* copy all format specifiers to our format string */
59 while (isdigit(*m) || strchr("#0-+. I", *m))
60@@ -639,7 +639,7 @@ void print_it(char *masterformat, char *filename,
61 }
62 else
63 {
64- printf(b);
65+ fputs(b,stdout);
66 b = NULL;
67 }
68 }