Bug Summary

File:src/usr.bin/doas/obj/parse.c
Warning:line 558, column 26
Use of zero-allocated memory

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name parse.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 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/usr.bin/doas/obj -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/usr.bin/doas -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.bin/doas/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c parse.c
1#include <stdlib.h>
2#include <string.h>
3#define YYBYACC1 1
4#define YYMAJOR1 1
5#define YYMINOR9 9
6#define YYLEXyylex() yylex()
7#define YYEMPTY-1 -1
8#define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1))
9#define yyerrok(yyerrflag=0) (yyerrflag=0)
10#define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0)
11#define YYPREFIX"yy" "yy"
12#line 19 "/usr/src/usr.bin/doas/parse.y"
13#include <sys/types.h>
14#include <ctype.h>
15#include <limits.h>
16#include <unistd.h>
17#include <stdint.h>
18#include <stdarg.h>
19#include <stdio.h>
20#include <string.h>
21#include <err.h>
22
23#include "doas.h"
24
25typedef struct {
26 union {
27 struct {
28 int action;
29 int options;
30 const char *cmd;
31 const char **cmdargs;
32 const char **envlist;
33 };
34 const char **strlist;
35 const char *str;
36 };
37 unsigned long lineno;
38 unsigned long colno;
39} yystype;
40#define YYSTYPEyystype yystype
41
42FILE *yyfp;
43
44struct rule **rules;
45size_t nrules;
46static size_t maxrules;
47
48int parse_error = 0;
49
50static void yyerror(const char *, ...);
51static int yylex(void);
52
53static size_t
54arraylen(const char **arr)
55{
56 size_t cnt = 0;
57
58 while (*arr) {
59 cnt++;
60 arr++;
61 }
62 return cnt;
63}
64
65#line 66 "parse.c"
66#define TPERMIT257 257
67#define TDENY258 258
68#define TAS259 259
69#define TCMD260 260
70#define TARGS261 261
71#define TNOPASS262 262
72#define TNOLOG263 263
73#define TPERSIST264 264
74#define TKEEPENV265 265
75#define TSETENV266 266
76#define TSTRING267 267
77#define YYERRCODE256 256
78const short yylhs[] =
79 { -1,
80 0, 0, 0, 0, 1, 2, 2, 6, 6, 7,
81 7, 7, 7, 7, 8, 8, 3, 4, 4, 5,
82 5, 9, 9,
83};
84const short yylen[] =
85 { 2,
86 0, 2, 3, 2, 4, 2, 1, 0, 2, 1,
87 1, 1, 1, 4, 0, 2, 1, 0, 2, 0,
88 3, 0, 2,
89};
90const short yydefred[] =
91 { 0,
92 0, 0, 4, 8, 7, 2, 0, 0, 0, 3,
93 17, 0, 10, 11, 12, 13, 0, 9, 0, 0,
94 15, 19, 0, 5, 0, 0, 16, 14, 15, 21,
95 0,
96};
97const short yydgoto[] =
98 { 2,
99 7, 8, 12, 20, 24, 9, 18, 25, 30,
100};
101const short yysindex[] =
102 { -253,
103 2, -6, 0, 0, 0, 0, 3, -252, -257, 0,
104 0, -249, 0, 0, 0, 0, -109, 0, -251, -243,
105 0, 0, -248, 0, -123, -241, 0, 0, 0, 0,
106 -246,};
107const short yyrindex[] =
108 { 1,
109 0, 0, 0, 0, 0, 0, 0, 0, -245, 0,
110 0, -10, 0, 0, 0, 0, 0, 0, 0, 8,
111 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
112 14,};
113const short yygindex[] =
114 { 0,
115 0, 0, 0, 0, 0, 0, 0, -4, 0,
116};
117#define YYTABLESIZE259 259
118const short yytable[] =
119 { 18,
120 1, 28, 1, 6, 13, 14, 15, 16, 17, 19,
121 1, 3, 10, 21, 11, 22, 23, 20, 26, 29,
122 27, 6, 22, 23, 31, 0, 0, 0, 0, 0,
123 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
124 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
126 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
127 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
132 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
133 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
134 0, 0, 0, 27, 0, 0, 0, 0, 0, 0,
135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
137 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
139 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 18,
145 4, 5, 0, 0, 0, 0, 0, 1, 1,
146};
147const short yycheck[] =
148 { 10,
149 0, 125, 256, 10, 262, 263, 264, 265, 266, 259,
150 10, 10, 10, 123, 267, 267, 260, 10, 267, 261,
151 267, 267, 10, 10, 29, -1, -1, -1, -1, -1,
152 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
153 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
154 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
155 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
156 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
157 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
158 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
159 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
160 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
161 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
162 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
163 -1, -1, -1, 267, -1, -1, -1, -1, -1, -1,
164 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
165 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
166 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
167 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
168 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
169 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
170 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
171 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
172 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
173 -1, -1, -1, -1, -1, -1, -1, -1, -1, 260,
174 257, 258, -1, -1, -1, -1, -1, 257, 258,
175};
176#define YYFINAL2 2
177#ifndef YYDEBUG0
178#define YYDEBUG0 0
179#endif
180#define YYMAXTOKEN267 267
181#if YYDEBUG0
182const char * const yyname[] =
183 {
184"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1850,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1860,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1870,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1880,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1890,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1900,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"TPERMIT","TDENY",
191"TAS","TCMD","TARGS","TNOPASS","TNOLOG","TPERSIST","TKEEPENV","TSETENV",
192"TSTRING",
193};
194const char * const yyrule[] =
195 {"$accept : grammar",
196"grammar :",
197"grammar : grammar '\\n'",
198"grammar : grammar rule '\\n'",
199"grammar : error '\\n'",
200"rule : action ident target cmd",
201"action : TPERMIT options",
202"action : TDENY",
203"options :",
204"options : options option",
205"option : TNOPASS",
206"option : TNOLOG",
207"option : TPERSIST",
208"option : TKEEPENV",
209"option : TSETENV '{' strlist '}'",
210"strlist :",
211"strlist : strlist TSTRING",
212"ident : TSTRING",
213"target :",
214"target : TAS TSTRING",
215"cmd :",
216"cmd : TCMD TSTRING args",
217"args :",
218"args : TARGS strlist",
219};
220#endif
221#ifndef YYSTYPEyystype
222typedef int YYSTYPEyystype;
223#endif
224#ifdef YYSTACKSIZE10000
225#undef YYMAXDEPTH10000
226#define YYMAXDEPTH10000 YYSTACKSIZE10000
227#else
228#ifdef YYMAXDEPTH10000
229#define YYSTACKSIZE10000 YYMAXDEPTH10000
230#else
231#define YYSTACKSIZE10000 10000
232#define YYMAXDEPTH10000 10000
233#endif
234#endif
235#define YYINITSTACKSIZE200 200
236/* LINTUSED */
237int yydebug;
238int yynerrs;
239int yyerrflag;
240int yychar;
241short *yyssp;
242YYSTYPEyystype *yyvsp;
243YYSTYPEyystype yyval;
244YYSTYPEyystype yylval;
245short *yyss;
246short *yysslim;
247YYSTYPEyystype *yyvs;
248unsigned int yystacksize;
249int yyparse(void);
250#line 192 "/usr/src/usr.bin/doas/parse.y"
251
252void
253yyerror(const char *fmt, ...)
254{
255 va_list va;
256
257 fprintf(stderr(&__sF[2]), "doas: ");
258 va_start(va, fmt)__builtin_va_start(va, fmt);
259 vfprintf(stderr(&__sF[2]), fmt, va);
260 va_end(va)__builtin_va_end(va);
261 fprintf(stderr(&__sF[2]), " at line %lu\n", yylval.lineno + 1);
262 parse_error = 1;
263}
264
265static struct keyword {
266 const char *word;
267 int token;
268} keywords[] = {
269 { "deny", TDENY258 },
270 { "permit", TPERMIT257 },
271 { "as", TAS259 },
272 { "cmd", TCMD260 },
273 { "args", TARGS261 },
274 { "nopass", TNOPASS262 },
275 { "nolog", TNOLOG263 },
276 { "persist", TPERSIST264 },
277 { "keepenv", TKEEPENV265 },
278 { "setenv", TSETENV266 },
279};
280
281int
282yylex(void)
283{
284 char buf[1024], *ebuf, *p, *str;
285 int c, quoted = 0, quotes = 0, qerr = 0, escape = 0, nonkw = 0;
286 unsigned long qpos = 0;
287 size_t i;
288
289 p = buf;
290 ebuf = buf + sizeof(buf);
291
292repeat:
293 /* skip whitespace first */
294 for (c = getc(yyfp)(!__isthreaded ? (--(yyfp)->_r < 0 ? __srget(yyfp) : (int
)(*(yyfp)->_p++)) : (getc)(yyfp))
; c == ' ' || c == '\t'; c = getc(yyfp)(!__isthreaded ? (--(yyfp)->_r < 0 ? __srget(yyfp) : (int
)(*(yyfp)->_p++)) : (getc)(yyfp))
)
295 yylval.colno++;
296
297 /* check for special one-character constructions */
298 switch (c) {
299 case '\n':
300 yylval.colno = 0;
301 yylval.lineno++;
302 /* FALLTHROUGH */
303 case '{':
304 case '}':
305 return c;
306 case '#':
307 /* skip comments; NUL is allowed; no continuation */
308 while ((c = getc(yyfp)(!__isthreaded ? (--(yyfp)->_r < 0 ? __srget(yyfp) : (int
)(*(yyfp)->_p++)) : (getc)(yyfp))
) != '\n')
309 if (c == EOF(-1))
310 goto eof;
311 yylval.colno = 0;
312 yylval.lineno++;
313 return c;
314 case EOF(-1):
315 goto eof;
316 }
317
318 /* parsing next word */
319 for (;; c = getc(yyfp)(!__isthreaded ? (--(yyfp)->_r < 0 ? __srget(yyfp) : (int
)(*(yyfp)->_p++)) : (getc)(yyfp))
, yylval.colno++) {
320 switch (c) {
321 case '\0':
322 yyerror("unallowed character NUL in column %lu",
323 yylval.colno + 1);
324 escape = 0;
325 continue;
326 case '\\':
327 escape = !escape;
328 if (escape)
329 continue;
330 break;
331 case '\n':
332 if (quotes && !qerr) {
333 yyerror("unterminated quotes in column %lu",
334 qpos + 1);
335 qerr = 1;
336 }
337 if (escape) {
338 nonkw = 1;
339 escape = 0;
340 yylval.colno = ULONG_MAX(9223372036854775807L *2UL+1UL);
341 yylval.lineno++;
342 continue;
343 }
344 goto eow;
345 case EOF(-1):
346 if (escape)
347 yyerror("unterminated escape in column %lu",
348 yylval.colno);
349 if (quotes && !qerr)
350 yyerror("unterminated quotes in column %lu",
351 qpos + 1);
352 goto eow;
353 case '{':
354 case '}':
355 case '#':
356 case ' ':
357 case '\t':
358 if (!escape && !quotes)
359 goto eow;
360 break;
361 case '"':
362 if (!escape) {
363 quoted = 1;
364 quotes = !quotes;
365 if (quotes) {
366 nonkw = 1;
367 qerr = 0;
368 qpos = yylval.colno;
369 }
370 continue;
371 }
372 }
373 *p++ = c;
374 if (p == ebuf) {
375 yyerror("too long line");
376 p = buf;
377 }
378 escape = 0;
379 }
380
381eow:
382 *p = 0;
383 if (c != EOF(-1))
384 ungetc(c, yyfp);
385 if (p == buf) {
386 /*
387 * There could be a number of reasons for empty buffer,
388 * and we handle all of them here, to avoid cluttering
389 * the main loop.
390 */
391 if (c == EOF(-1))
392 goto eof;
393 else if (!quoted) /* accept, e.g., empty args: cmd foo args "" */
394 goto repeat;
395 }
396 if (!nonkw) {
397 for (i = 0; i < sizeof(keywords) / sizeof(keywords[0]); i++) {
398 if (strcmp(buf, keywords[i].word) == 0)
399 return keywords[i].token;
400 }
401 }
402 if ((str = strdup(buf)) == NULL((void *)0))
403 err(1, "%s", __func__);
404 yylval.str = str;
405 return TSTRING267;
406
407eof:
408 if (ferror(yyfp)(!__isthreaded ? (((yyfp)->_flags & 0x0040) != 0) : (ferror
)(yyfp))
)
409 yyerror("input error reading config");
410 return 0;
411}
412#line 405 "parse.c"
413/* allocate initial stack or double stack size, up to YYMAXDEPTH */
414static int yygrowstack(void)
415{
416 unsigned int newsize;
417 long sslen;
418 short *newss;
419 YYSTYPEyystype *newvs;
420
421 if ((newsize = yystacksize) == 0)
21
Assuming the condition is false
22
Taking false branch
422 newsize = YYINITSTACKSIZE200;
423 else if (newsize >= YYMAXDEPTH10000)
23
Assuming 'newsize' is < YYMAXDEPTH
24
Taking false branch
424 return -1;
425 else if ((newsize *= 2) > YYMAXDEPTH10000)
25
Assuming the condition is false
26
Taking false branch
426 newsize = YYMAXDEPTH10000;
427 sslen = yyssp - yyss;
428#ifdef SIZE_MAX0xffffffffffffffffUL
429#define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL
430#else
431#define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU
432#endif
433 if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss)
27
Assuming 'newsize' is 0
434 goto bail;
435 newss = (short *)realloc(yyss, newsize * sizeof *newss);
436 if (newss == NULL((void *)0))
28
Assuming 'newss' is not equal to NULL
29
Taking false branch
437 goto bail;
438 yyss = newss;
439 yyssp = newss + sslen;
440 if (newsize
29.1
'newsize' is 0
&& YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newvs)
441 goto bail;
442 newvs = (YYSTYPEyystype *)realloc(yyvs, newsize * sizeof *newvs);
443 if (newvs == NULL((void *)0))
30
Assuming 'newvs' is not equal to NULL
31
Taking false branch
444 goto bail;
445 yyvs = newvs;
446 yyvsp = newvs + sslen;
447 yystacksize = newsize;
448 yysslim = yyss + newsize - 1;
449 return 0;
450bail:
451 if (yyss)
452 free(yyss);
453 if (yyvs)
454 free(yyvs);
455 yyss = yyssp = NULL((void *)0);
456 yyvs = yyvsp = NULL((void *)0);
457 yystacksize = 0;
458 return -1;
459}
460
461#define YYABORTgoto yyabort goto yyabort
462#define YYREJECTgoto yyabort goto yyabort
463#define YYACCEPTgoto yyaccept goto yyaccept
464#define YYERRORgoto yyerrlab goto yyerrlab
465int
466yyparse(void)
467{
468 int yym, yyn, yystate;
469#if YYDEBUG0
470 const char *yys;
471
472 if ((yys = getenv("YYDEBUG")))
473 {
474 yyn = *yys;
475 if (yyn >= '0' && yyn <= '9')
476 yydebug = yyn - '0';
477 }
478#endif /* YYDEBUG */
479
480 yynerrs = 0;
481 yyerrflag = 0;
482 yychar = (-1);
483
484 if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow;
1
Assuming 'yyss' is not equal to NULL
485 yyssp = yyss;
486 yyvsp = yyvs;
487 *yyssp = yystate = 0;
488
489yyloop:
490 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
2
Taking false branch
491 if (yychar
2.1
'yychar' is < 0
< 0)
3
Taking true branch
492 {
493 if ((yychar = yylex()) < 0) yychar = 0;
4
Taking false branch
494#if YYDEBUG0
495 if (yydebug)
496 {
497 yys = 0;
498 if (yychar <= YYMAXTOKEN267) yys = yyname[yychar];
499 if (!yys) yys = "illegal-symbol";
500 printf("%sdebug: state %d, reading %d (%s)\n",
501 YYPREFIX"yy", yystate, yychar, yys);
502 }
503#endif
504 }
505 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
5
Assuming 'yyn' is not equal to 0
506 yyn <= YYTABLESIZE259 && yycheck[yyn] == yychar)
507 {
508#if YYDEBUG0
509 if (yydebug)
510 printf("%sdebug: state %d, shifting to state %d\n",
511 YYPREFIX"yy", yystate, yytable[yyn]);
512#endif
513 if (yyssp >= yysslim && yygrowstack())
514 {
515 goto yyoverflow;
516 }
517 *++yyssp = yystate = yytable[yyn];
518 *++yyvsp = yylval;
519 yychar = (-1);
520 if (yyerrflag > 0) --yyerrflag;
521 goto yyloop;
522 }
523 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
6
Assuming 'yyn' is not equal to 0
7
Taking false branch
524 yyn
6.1
'yyn' is <= YYTABLESIZE
<= YYTABLESIZE259 && yycheck[yyn] == yychar)
525 {
526 yyn = yytable[yyn];
527 goto yyreduce;
528 }
529 if (yyerrflag
7.1
'yyerrflag' is 0
) goto yyinrecovery;
8
Taking false branch
530#if defined(__GNUC__4)
531 goto yynewerror;
9
Control jumps to line 534
532#endif
533yynewerror:
534 yyerror("syntax error");
535#if defined(__GNUC__4)
536 goto yyerrlab;
10
Control jumps to line 539
537#endif
538yyerrlab:
539 ++yynerrs;
540yyinrecovery:
541 if (yyerrflag < 3)
11
Assuming 'yyerrflag' is < 3
12
Taking true branch
542 {
543 yyerrflag = 3;
544 for (;;)
13
Loop condition is true. Entering loop body
545 {
546 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 &&
14
Assuming 'yyn' is not equal to 0
15
Assuming the condition is true
18
Taking true branch
547 yyn <= YYTABLESIZE259 && yycheck[yyn] == YYERRCODE256)
16
Assuming 'yyn' is <= YYTABLESIZE
17
Assuming the condition is true
548 {
549#if YYDEBUG0
550 if (yydebug)
551 printf("%sdebug: state %d, error recovery shifting\
552 to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]);
553#endif
554 if (yyssp >= yysslim && yygrowstack())
19
Assuming 'yyssp' is >= 'yysslim'
20
Calling 'yygrowstack'
32
Returning from 'yygrowstack'
33
Taking false branch
555 {
556 goto yyoverflow;
557 }
558 *++yyssp = yystate = yytable[yyn];
34
Use of zero-allocated memory
559 *++yyvsp = yylval;
560 goto yyloop;
561 }
562 else
563 {
564#if YYDEBUG0
565 if (yydebug)
566 printf("%sdebug: error recovery discarding state %d\n",
567 YYPREFIX"yy", *yyssp);
568#endif
569 if (yyssp <= yyss) goto yyabort;
570 --yyssp;
571 --yyvsp;
572 }
573 }
574 }
575 else
576 {
577 if (yychar == 0) goto yyabort;
578#if YYDEBUG0
579 if (yydebug)
580 {
581 yys = 0;
582 if (yychar <= YYMAXTOKEN267) yys = yyname[yychar];
583 if (!yys) yys = "illegal-symbol";
584 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
585 YYPREFIX"yy", yystate, yychar, yys);
586 }
587#endif
588 yychar = (-1);
589 goto yyloop;
590 }
591yyreduce:
592#if YYDEBUG0
593 if (yydebug)
594 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
595 YYPREFIX"yy", yystate, yyn, yyrule[yyn]);
596#endif
597 yym = yylen[yyn];
598 if (yym)
599 yyval = yyvsp[1-yym];
600 else
601 memset(&yyval, 0, sizeof yyval);
602 switch (yyn)
603 {
604case 5:
605#line 85 "/usr/src/usr.bin/doas/parse.y"
606{
607 struct rule *r;
608 r = calloc(1, sizeof(*r));
609 if (!r)
610 errx(1, "can't allocate rule");
611 r->action = yyvsp[-3].action;
612 r->options = yyvsp[-3].options;
613 r->envlist = yyvsp[-3].envlist;
614 r->ident = yyvsp[-2].str;
615 r->target = yyvsp[-1].str;
616 r->cmd = yyvsp[0].cmd;
617 r->cmdargs = yyvsp[0].cmdargs;
618 if (nrules == maxrules) {
619 if (maxrules == 0)
620 maxrules = 32;
621 rules = reallocarray(rules, maxrules,
622 2 * sizeof(*rules));
623 if (!rules)
624 errx(1, "can't allocate rules");
625 maxrules *= 2;
626 }
627 rules[nrules++] = r;
628 }
629break;
630case 6:
631#line 109 "/usr/src/usr.bin/doas/parse.y"
632{
633 yyval.action = PERMIT1;
634 yyval.options = yyvsp[0].options;
635 yyval.envlist = yyvsp[0].envlist;
636 }
637break;
638case 7:
639#line 113 "/usr/src/usr.bin/doas/parse.y"
640{
641 yyval.action = DENY2;
642 yyval.options = 0;
643 yyval.envlist = NULL((void *)0);
644 }
645break;
646case 8:
647#line 119 "/usr/src/usr.bin/doas/parse.y"
648{
649 yyval.options = 0;
650 yyval.envlist = NULL((void *)0);
651 }
652break;
653case 9:
654#line 122 "/usr/src/usr.bin/doas/parse.y"
655{
656 yyval.options = yyvsp[-1].options | yyvsp[0].options;
657 yyval.envlist = yyvsp[-1].envlist;
658 if ((yyval.options & (NOPASS0x1|PERSIST0x4)) == (NOPASS0x1|PERSIST0x4)) {
659 yyerror("can't combine nopass and persist");
660 YYERRORgoto yyerrlab;
661 }
662 if (yyvsp[0].envlist) {
663 if (yyval.envlist) {
664 yyerror("can't have two setenv sections");
665 YYERRORgoto yyerrlab;
666 } else
667 yyval.envlist = yyvsp[0].envlist;
668 }
669 }
670break;
671case 10:
672#line 137 "/usr/src/usr.bin/doas/parse.y"
673{
674 yyval.options = NOPASS0x1;
675 yyval.envlist = NULL((void *)0);
676 }
677break;
678case 11:
679#line 140 "/usr/src/usr.bin/doas/parse.y"
680{
681 yyval.options = NOLOG0x8;
682 yyval.envlist = NULL((void *)0);
683 }
684break;
685case 12:
686#line 143 "/usr/src/usr.bin/doas/parse.y"
687{
688 yyval.options = PERSIST0x4;
689 yyval.envlist = NULL((void *)0);
690 }
691break;
692case 13:
693#line 146 "/usr/src/usr.bin/doas/parse.y"
694{
695 yyval.options = KEEPENV0x2;
696 yyval.envlist = NULL((void *)0);
697 }
698break;
699case 14:
700#line 149 "/usr/src/usr.bin/doas/parse.y"
701{
702 yyval.options = 0;
703 yyval.envlist = yyvsp[-1].strlist;
704 }
705break;
706case 15:
707#line 154 "/usr/src/usr.bin/doas/parse.y"
708{
709 if (!(yyval.strlist = calloc(1, sizeof(char *))))
710 errx(1, "can't allocate strlist");
711 }
712break;
713case 16:
714#line 157 "/usr/src/usr.bin/doas/parse.y"
715{
716 int nstr = arraylen(yyvsp[-1].strlist);
717 if (!(yyval.strlist = reallocarray(yyvsp[-1].strlist, nstr + 2,
718 sizeof(char *))))
719 errx(1, "can't allocate strlist");
720 yyval.strlist[nstr] = yyvsp[0].str;
721 yyval.strlist[nstr + 1] = NULL((void *)0);
722 }
723break;
724case 17:
725#line 167 "/usr/src/usr.bin/doas/parse.y"
726{
727 yyval.str = yyvsp[0].str;
728 }
729break;
730case 18:
731#line 171 "/usr/src/usr.bin/doas/parse.y"
732{
733 yyval.str = NULL((void *)0);
734 }
735break;
736case 19:
737#line 173 "/usr/src/usr.bin/doas/parse.y"
738{
739 yyval.str = yyvsp[0].str;
740 }
741break;
742case 20:
743#line 177 "/usr/src/usr.bin/doas/parse.y"
744{
745 yyval.cmd = NULL((void *)0);
746 yyval.cmdargs = NULL((void *)0);
747 }
748break;
749case 21:
750#line 180 "/usr/src/usr.bin/doas/parse.y"
751{
752 yyval.cmd = yyvsp[-1].str;
753 yyval.cmdargs = yyvsp[0].cmdargs;
754 }
755break;
756case 22:
757#line 185 "/usr/src/usr.bin/doas/parse.y"
758{
759 yyval.cmdargs = NULL((void *)0);
760 }
761break;
762case 23:
763#line 187 "/usr/src/usr.bin/doas/parse.y"
764{
765 yyval.cmdargs = yyvsp[0].strlist;
766 }
767break;
768#line 761 "parse.c"
769 }
770 yyssp -= yym;
771 yystate = *yyssp;
772 yyvsp -= yym;
773 yym = yylhs[yyn];
774 if (yystate == 0 && yym == 0)
775 {
776#if YYDEBUG0
777 if (yydebug)
778 printf("%sdebug: after reduction, shifting from state 0 to\
779 state %d\n", YYPREFIX"yy", YYFINAL2);
780#endif
781 yystate = YYFINAL2;
782 *++yyssp = YYFINAL2;
783 *++yyvsp = yyval;
784 if (yychar < 0)
785 {
786 if ((yychar = yylex()) < 0) yychar = 0;
787#if YYDEBUG0
788 if (yydebug)
789 {
790 yys = 0;
791 if (yychar <= YYMAXTOKEN267) yys = yyname[yychar];
792 if (!yys) yys = "illegal-symbol";
793 printf("%sdebug: state %d, reading %d (%s)\n",
794 YYPREFIX"yy", YYFINAL2, yychar, yys);
795 }
796#endif
797 }
798 if (yychar == 0) goto yyaccept;
799 goto yyloop;
800 }
801 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
802 yyn <= YYTABLESIZE259 && yycheck[yyn] == yystate)
803 yystate = yytable[yyn];
804 else
805 yystate = yydgoto[yym];
806#if YYDEBUG0
807 if (yydebug)
808 printf("%sdebug: after reduction, shifting from state %d \
809to state %d\n", YYPREFIX"yy", *yyssp, yystate);
810#endif
811 if (yyssp >= yysslim && yygrowstack())
812 {
813 goto yyoverflow;
814 }
815 *++yyssp = yystate;
816 *++yyvsp = yyval;
817 goto yyloop;
818yyoverflow:
819 yyerror("yacc stack overflow");
820yyabort:
821 if (yyss)
822 free(yyss);
823 if (yyvs)
824 free(yyvs);
825 yyss = yyssp = NULL((void *)0);
826 yyvs = yyvsp = NULL((void *)0);
827 yystacksize = 0;
828 return (1);
829yyaccept:
830 if (yyss)
831 free(yyss);
832 if (yyvs)
833 free(yyvs);
834 yyss = yyssp = NULL((void *)0);
835 yyvs = yyvsp = NULL((void *)0);
836 yystacksize = 0;
837 return (0);
838}