clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name _unix.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -std=gnu89 -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -stack-protector 2 -fgnuc-version=4.2.1 -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c /home/maarten/src/libreoffice/core/soltools/cpp/_unix.c
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | #include <stdio.h> |
21 | #include <stddef.h> |
22 | #include <stdlib.h> |
23 | #include <string.h> |
24 | #include <ctype.h> |
25 | #include <fcntl.h> |
26 | #if (defined(_WIN32) || defined(__IBMC__)) |
27 | #include <io.h> |
28 | #else |
29 | #include <unistd.h> |
30 | #endif |
31 | |
32 | #include "cpp.h" |
33 | |
34 | #if defined(MACOSX) || defined(AIX) || defined(_WIN32) |
35 | #include "_getopt.h" |
36 | #else |
37 | #include <getopt.h> |
38 | #endif |
39 | |
40 | int Pflag = 0; |
41 | int Iflag = 0; |
42 | int Mflag = 0; |
43 | int Aflag = 0; |
44 | int Xflag = 0; |
45 | int Vflag = 0; |
46 | int Cflag = 0; |
47 | int Dflag = 0; |
48 | int Cplusplus = 0; |
49 | |
50 | void |
51 | setup(int argc, char **argv) |
52 | { |
53 | int c, fd, i, n; |
54 | char *fp, *dp; |
55 | Tokenrow tr; |
56 | |
57 | setup_kwtab(); |
58 | #if defined(MACOSX) || defined(AIX) || defined(_WIN32) |
59 | while ((c = stgetopt(argc, argv, "NOPV:I:D:U:F:A:X:u:l:+")) != -1) |
60 | #else |
61 | while ((c = getopt(argc, argv, "NOPV:I:D:U:F:A:X:u:l:+")) != -1) |
| 1 | Assuming the condition is true | |
|
| 2 | | Loop condition is true. Entering loop body | |
|
| 10 | | Assuming the condition is true | |
|
| 11 | | Loop condition is true. Entering loop body | |
|
| 19 | | Assuming the condition is true | |
|
| 20 | | Loop condition is true. Entering loop body | |
|
62 | #endif |
63 | switch (c) |
| 3 | | Control jumps to 'case 73:' at line 71 | |
|
| 12 | | Control jumps to 'case 73:' at line 71 | |
|
| 21 | | Control jumps to 'case 88:' at line 135 | |
|
64 | { |
65 | case 'N': |
66 | for (i = 0; i < NINCLUDE; i++) |
67 | if (includelist[i].always == 1) |
68 | includelist[i].deleted = 1; |
69 | break; |
70 | |
71 | case 'I': |
72 | for (i = NINCLUDE - 2; i >= 0; i--) |
| 4 | | Loop condition is true. Entering loop body | |
|
| 13 | | Loop condition is true. Entering loop body | |
|
73 | { |
74 | if (includelist[i].file == NULL) |
| 5 | | Assuming field 'file' is equal to NULL | |
|
| |
| 14 | | Assuming field 'file' is equal to NULL | |
|
| |
75 | { |
76 | includelist[i].always = 1; |
77 | includelist[i].file = optarg; |
78 | break; |
| 7 | | Execution continues on line 81 | |
|
| 16 | | Execution continues on line 81 | |
|
79 | } |
80 | } |
81 | if (i < 0) |
| |
| |
82 | error(FATAL, "Too many -I directives"); |
83 | break; |
| 9 | | Execution continues on line 61 | |
|
| 18 | | Execution continues on line 61 | |
|
84 | |
85 | case 'D': |
86 | case 'U': |
87 | case 'A': |
88 | setsource("<cmdarg>", -1, -1, optarg, 0); |
89 | maketokenrow(3, &tr); |
90 | |
91 | gettokens(&tr, 1); |
92 | doadefine(&tr, c); |
93 | dofree(tr.bp); |
94 | unsetsource(); |
95 | break; |
96 | |
97 | case 'P': |
98 | Pflag++; |
99 | break; |
100 | |
101 | case 'V': |
102 | for (n = 0;; n++) |
103 | { |
104 | c = optarg[n]; |
105 | if (c == '\0') |
106 | break; |
107 | switch (c) |
108 | { |
109 | case 'i': |
110 | Iflag++; |
111 | break; |
112 | |
113 | case 'm': |
114 | Mflag = 1; |
115 | break; |
116 | |
117 | case 'x': |
118 | Mflag = 2; |
119 | break; |
120 | |
121 | case 't': |
122 | Vflag++; |
123 | break; |
124 | |
125 | case 'v': |
126 | fprintf(stderr, "%s\n", argv[0]); |
127 | break; |
128 | |
129 | default: |
130 | error(WARNING, "Unknown verbose option %c", c); |
131 | } |
132 | } |
133 | break; |
134 | |
135 | case 'X': |
136 | for (n = 0;; n++) |
| 22 | | Loop condition is true. Entering loop body | |
|
137 | { |
138 | c = optarg[n]; |
| 23 | | Array access (from variable 'optarg') results in a null pointer dereference |
|
139 | if (c == '\0') |
140 | break; |
141 | switch (c) |
142 | { |
143 | case 'a': |
144 | Aflag++; |
145 | break; |
146 | |
147 | case 'i': |
148 | Xflag++; |
149 | break; |
150 | |
151 | case 'c': |
152 | Cflag++; |
153 | break; |
154 | |
155 | case 'd': |
156 | Dflag++; |
157 | break; |
158 | |
159 | case 'w': |
160 | dp = &optarg[n + 1]; |
161 | n += (int)strlen(dp); |
162 | while (isspace((unsigned char)*dp)) dp++; |
163 | |
164 | for (i = NINCLUDE - 1; i >= 0; i--) |
165 | { |
166 | if (wraplist[i].file == NULL) |
167 | { |
168 | wraplist[i].file = dp; |
169 | break; |
170 | } |
171 | } |
172 | if (i < 0) |
173 | error(WARNING, "Too many -Xw directives"); |
174 | break; |
175 | |
176 | default: |
177 | error(WARNING, "Unknown extension option %c", c); |
178 | } |
179 | } |
180 | break; |
181 | |
182 | case '+': |
183 | Cplusplus++; |
184 | break; |
185 | |
186 | case 'u': |
187 | case 'l': |
188 | break; |
189 | |
190 | default: |
191 | break; |
192 | } |
193 | dp = "."; |
194 | fp = "<stdin>"; |
195 | fd = 0; |
196 | if (optind < argc) |
197 | { |
198 | if ((fp = strrchr(argv[optind], '/')) != NULL) |
199 | { |
200 | int len = (int)(fp - argv[optind]); |
201 | |
202 | dp = (char *) newstring((uchar *) argv[optind], len + 1, 0); |
203 | dp[len] = '\0'; |
204 | } |
205 | fp = (char *) newstring((uchar *) argv[optind], strlen(argv[optind]), 0); |
206 | if ((fd = open(fp, O_RDONLY)) <= 0) |
207 | error(FATAL, "Can't open input file %s", fp); |
208 | } |
209 | |
210 | if (optind + 1 < argc) |
211 | { |
212 | int fdo = creat(argv[optind + 1], 0666); |
213 | |
214 | if (fdo < 0) |
215 | error(FATAL, "Can't open output file %s", argv[optind + 1]); |
216 | |
217 | dup2(fdo, 1); |
218 | |
219 | } |
220 | includelist[NINCLUDE - 1].always = 0; |
221 | includelist[NINCLUDE - 1].file = dp; |
222 | setsource(fp, -1, fd, NULL, 0); |
223 | } |
224 | |
225 | |
226 | |