Bug Summary

File:src/usr.sbin/iscsictl/obj/parse.c
Warning:line 844, column 13
Attempt to free released 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.sbin/iscsictl/obj -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/usr.sbin/iscsictl -I /usr/src/usr.sbin/iscsictl/../iscsid -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.sbin/iscsictl/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 26 "/usr/src/usr.sbin/iscsictl/parse.y"
13#include <sys/types.h>
14#include <sys/queue.h>
15#include <sys/socket.h>
16#include <sys/stat.h>
17#include <sys/uio.h>
18#include <netinet/in.h>
19#include <arpa/inet.h>
20#include <ctype.h>
21#include <err.h>
22#include <errno(*__errno()).h>
23#include <event.h>
24#include <limits.h>
25#include <netdb.h>
26#include <stdarg.h>
27#include <stdio.h>
28#include <string.h>
29#include <unistd.h>
30
31#include <scsi/iscsi.h>
32#include "iscsid.h"
33#include "iscsictl.h"
34
35TAILQ_HEAD(files, file)struct files { struct file *tqh_first; struct file **tqh_last
; }
files = TAILQ_HEAD_INITIALIZER(files){ ((void *)0), &(files).tqh_first };
36static struct file {
37 TAILQ_ENTRY(file)struct { struct file *tqe_next; struct file **tqe_prev; } entry;
38 FILE *stream;
39 char *name;
40 size_t ungetpos;
41 size_t ungetsize;
42 u_char *ungetbuf;
43 int eof_reached;
44 int lineno;
45 int errors;
46} *file, *topfile;
47struct file *pushfile(const char *, int);
48int popfile(void);
49int yyparse(void);
50int yylex(void);
51int yyerror(const char *, ...)
52 __attribute__((__format__ (printf, 1, 2)))
53 __attribute__((__nonnull__ (1)));
54int kw_cmp(const void *, const void *);
55int lookup(char *);
56int igetc(void);
57int lgetc(int);
58void lungetc(int);
59int findeol(void);
60
61void clear_config(struct iscsi_config *);
62
63TAILQ_HEAD(symhead, sym)struct symhead { struct sym *tqh_first; struct sym **tqh_last
; }
symhead = TAILQ_HEAD_INITIALIZER(symhead){ ((void *)0), &(symhead).tqh_first };
64struct sym {
65 TAILQ_ENTRY(sym)struct { struct sym *tqe_next; struct sym **tqe_prev; } entry;
66 int used;
67 int persist;
68 char *nam;
69 char *val;
70};
71int symset(const char *, const char *, int);
72char *symget(const char *);
73
74static int errors;
75static struct iscsi_config *conf;
76static struct session_config *session;
77
78struct addrinfo_opts {
79 int af;
80 char *port;
81} addrinfo_opts;
82
83typedef struct {
84 union {
85 int i;
86 int64_t number;
87 char *string;
88 struct addrinfo_opts addrinfo_opts;
89 struct addrinfo *addrinfo;
90 } v;
91 int lineno;
92} YYSTYPE;
93
94#line 95 "parse.c"
95#define TARGET257 257
96#define TARGETNAME258 258
97#define TARGETADDR259 259
98#define INITIATORNAME260 260
99#define INITIATORADDR261 261
100#define ISID262 262
101#define ENABLED263 263
102#define DISABLED264 264
103#define NORMAL265 265
104#define DISCOVERY266 266
105#define ADDRESS267 267
106#define INET268 268
107#define INET6269 269
108#define PORT270 270
109#define INCLUDE271 271
110#define ERROR272 272
111#define STRING273 273
112#define NUMBER274 274
113#define YYERRCODE256 256
114const short yylhs[] =
115 { -1,
116 0, 0, 0, 0, 0, 0, 0, 10, 9, 9,
117 11, 14, 14, 15, 12, 16, 13, 17, 17, 18,
118 18, 18, 18, 18, 18, 5, 19, 6, 6, 7,
119 7, 8, 8, 4, 1, 1, 2, 2, 3, 3,
120};
121const short yylen[] =
122 { 2,
123 0, 2, 3, 3, 3, 3, 3, 2, 2, 1,
124 3, 2, 0, 2, 4, 0, 7, 3, 2, 1,
125 1, 2, 2, 2, 2, 2, 0, 2, 0, 2,
126 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,
127};
128const short yydefred[] =
129 { 1,
130 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
131 0, 7, 16, 0, 8, 0, 3, 4, 5, 6,
132 0, 0, 10, 0, 0, 15, 9, 0, 0, 12,
133 0, 0, 0, 0, 37, 38, 39, 40, 20, 21,
134 0, 0, 22, 0, 24, 23, 25, 17, 0, 19,
135 26, 0, 0, 18, 35, 36, 0, 33, 32, 0,
136 31, 14, 34, 30,
137};
138const short yydgoto[] =
139 { 1,
140 58, 39, 40, 59, 45, 51, 60, 61, 24, 8,
141 9, 10, 11, 29, 54, 21, 41, 42, 52,
142};
143const short yysindex[] =
144 { 0,
145 -10, -8, -266, -265, -263, -52, 0, 1, 3, 4,
146 5, 0, 0, -252, 0, -246, 0, 0, 0, 0,
147 -89, -235, 0, -233, 31, 0, 0, 31, -240, 0,
148 -231, -230, -229, -230, 0, 0, 0, 0, 0, 0,
149 -124, 31, 0, 0, 0, 0, 0, 0, 35, 0,
150 0, -264, 31, 0, 0, 0, -227, 0, 0, -264,
151 0, 0, 0, 0,};
152const short yyrindex[] =
153 { 0,
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 37, -228, 0, 0, -113, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, -113, 0, 6, 0, 0, 0, 0, 0, 0,
159 0, 0, -113, 0, 0, 0, 0, 0, 0, 19,
160 0, 0, 0, 0,};
161const short yygindex[] =
162 { 0,
163 0, 0, 0, 0, 14, 0, 0, -11, 0, 0,
164 0, 0, 0, -25, 0, 0, 0, 9, 0,
165};
166#define YYTABLESIZE285 285
167const short yytable[] =
168 { 7,
169 48, 12, 30, 55, 56, 57, 13, 14, 16, 15,
170 17, 13, 18, 19, 20, 29, 50, 31, 32, 33,
171 34, 22, 35, 36, 37, 38, 23, 62, 28, 13,
172 13, 13, 13, 25, 13, 13, 13, 13, 26, 27,
173 28, 43, 44, 46, 53, 63, 11, 47, 64, 49,
174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
178 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
181 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
182 29, 0, 0, 31, 32, 33, 34, 0, 35, 36,
183 37, 38, 0, 28, 13, 13, 13, 13, 0, 13,
184 13, 13, 13, 0, 0, 0, 0, 0, 0, 0,
185 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
186 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
189 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
190 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
191 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
192 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
193 0, 0, 0, 0, 0, 2, 3, 0, 0, 0,
194 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
195 5, 0, 6, 29, 29, 29, 29, 0, 29, 29,
196 29, 29, 0, 27, 27, 27, 28, 28, 28, 28,
197 0, 28, 28, 28, 28,
198};
199const short yycheck[] =
200 { 10,
201 125, 10, 28, 268, 269, 270, 273, 273, 61, 273,
202 10, 125, 10, 10, 10, 10, 42, 258, 259, 260,
203 261, 274, 263, 264, 265, 266, 273, 53, 10, 258,
204 259, 260, 261, 123, 263, 264, 265, 266, 274, 273,
205 10, 273, 273, 273, 10, 273, 10, 34, 60, 41,
206 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
207 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
208 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
209 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
210 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
211 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
212 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
213 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
214 125, -1, -1, 258, 259, 260, 261, -1, 263, 264,
215 265, 266, -1, 125, 258, 259, 260, 261, -1, 263,
216 264, 265, 266, -1, -1, -1, -1, -1, -1, -1,
217 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
218 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
219 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
220 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
221 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
222 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
223 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
224 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
225 -1, -1, -1, -1, -1, 256, 257, -1, -1, -1,
226 -1, 262, -1, -1, -1, -1, -1, -1, -1, -1,
227 271, -1, 273, 258, 259, 260, 261, -1, 263, 264,
228 265, 266, -1, 268, 269, 270, 258, 259, 260, 261,
229 -1, 263, 264, 265, 266,
230};
231#define YYFINAL1 1
232#ifndef YYDEBUG0
233#define YYDEBUG0 0
234#endif
235#define YYMAXTOKEN274 274
236#if YYDEBUG0
237const char * const yyname[] =
238 {
239"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,
2400,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,
2410,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,
2420,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,
2430,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,
2440,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,
2450,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,"TARGET",
246"TARGETNAME","TARGETADDR","INITIATORNAME","INITIATORADDR","ISID","ENABLED",
247"DISABLED","NORMAL","DISCOVERY","ADDRESS","INET","INET6","PORT","INCLUDE",
248"ERROR","STRING","NUMBER",
249};
250const char * const yyrule[] =
251 {"$accept : grammar",
252"grammar :",
253"grammar : grammar '\\n'",
254"grammar : grammar include '\\n'",
255"grammar : grammar varset '\\n'",
256"grammar : grammar initiator '\\n'",
257"grammar : grammar target '\\n'",
258"grammar : grammar error '\\n'",
259"include : INCLUDE STRING",
260"string : string STRING",
261"string : STRING",
262"varset : STRING '=' string",
263"optnl : '\\n' optnl",
264"optnl :",
265"nl : '\\n' optnl",
266"initiator : ISID STRING NUMBER NUMBER",
267"$$1 :",
268"target : TARGET STRING $$1 '{' optnl targetopts_l '}'",
269"targetopts_l : targetopts_l targetoptsl nl",
270"targetopts_l : targetoptsl optnl",
271"targetoptsl : state",
272"targetoptsl : type",
273"targetoptsl : TARGETNAME STRING",
274"targetoptsl : INITIATORNAME STRING",
275"targetoptsl : TARGETADDR addrinfo",
276"targetoptsl : INITIATORADDR addrinfo",
277"addrinfo : STRING addrinfo_opts",
278"$$2 :",
279"addrinfo_opts : $$2 addrinfo_opts_l",
280"addrinfo_opts :",
281"addrinfo_opts_l : addrinfo_opts_l addrinfo_opt",
282"addrinfo_opts_l : addrinfo_opt",
283"addrinfo_opt : port",
284"addrinfo_opt : af",
285"port : PORT STRING",
286"af : INET",
287"af : INET6",
288"state : ENABLED",
289"state : DISABLED",
290"type : NORMAL",
291"type : DISCOVERY",
292};
293#endif
294#ifdef YYSTACKSIZE10000
295#undef YYMAXDEPTH10000
296#define YYMAXDEPTH10000 YYSTACKSIZE10000
297#else
298#ifdef YYMAXDEPTH10000
299#define YYSTACKSIZE10000 YYMAXDEPTH10000
300#else
301#define YYSTACKSIZE10000 10000
302#define YYMAXDEPTH10000 10000
303#endif
304#endif
305#define YYINITSTACKSIZE200 200
306/* LINTUSED */
307int yydebug;
308int yynerrs;
309int yyerrflag;
310int yychar;
311short *yyssp;
312YYSTYPE *yyvsp;
313YYSTYPE yyval;
314YYSTYPE yylval;
315short *yyss;
316short *yysslim;
317YYSTYPE *yyvs;
318unsigned int yystacksize;
319int yyparse(void);
320#line 342 "/usr/src/usr.sbin/iscsictl/parse.y"
321
322struct keywords {
323 const char *k_name;
324 int k_val;
325};
326
327int
328yyerror(const char *fmt, ...)
329{
330 va_list ap;
331
332 file->errors++;
333 va_start(ap, fmt)__builtin_va_start(ap, fmt);
334 fprintf(stderr(&__sF[2]), "%s:%d: ", file->name, yylval.lineno);
335 vfprintf(stderr(&__sF[2]), fmt, ap);
336 fprintf(stderr(&__sF[2]), "\n");
337 va_end(ap)__builtin_va_end(ap);
338 return (0);
339}
340
341int
342kw_cmp(const void *k, const void *e)
343{
344 return (strcmp(k, ((const struct keywords *)e)->k_name));
345}
346
347int
348lookup(char *s)
349{
350 /* this has to be sorted always */
351 static const struct keywords keywords[] = {
352 {"address", ADDRESS267},
353 {"disabled", DISABLED264},
354 {"discovery", DISCOVERY266},
355 {"enabled", ENABLED263},
356 {"include", INCLUDE271},
357 {"inet", INET268},
358 {"inet4", INET268},
359 {"inet6", INET6269},
360 {"initiatoraddr", INITIATORADDR261},
361 {"initiatorname", INITIATORNAME260},
362 {"isid", ISID262},
363 {"normal", NORMAL265},
364 {"port", PORT270},
365 {"target", TARGET257},
366 {"targetaddr", TARGETADDR259},
367 {"targetname", TARGETNAME258}
368 };
369 const struct keywords *p;
370
371 p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
372 sizeof(keywords[0]), kw_cmp);
373
374 if (p)
375 return (p->k_val);
376 else
377 return (STRING273);
378}
379
380#define START_EXPAND1 1
381#define DONE_EXPAND2 2
382
383static int expanding;
384
385int
386igetc(void)
387{
388 int c;
389
390 while (1) {
391 if (file->ungetpos > 0)
392 c = file->ungetbuf[--file->ungetpos];
393 else
394 c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget
(file->stream) : (int)(*(file->stream)->_p++)) : (getc
)(file->stream))
;
395
396 if (c == START_EXPAND1)
397 expanding = 1;
398 else if (c == DONE_EXPAND2)
399 expanding = 0;
400 else
401 break;
402 }
403 return (c);
404}
405
406int
407lgetc(int quotec)
408{
409 int c, next;
410
411 if (quotec) {
412 if ((c = igetc()) == EOF(-1)) {
413 yyerror("reached end of file while parsing "
414 "quoted string");
415 if (file == topfile || popfile() == EOF(-1))
416 return (EOF(-1));
417 return (quotec);
418 }
419 return (c);
420 }
421
422 while ((c = igetc()) == '\\') {
423 next = igetc();
424 if (next != '\n') {
425 c = next;
426 break;
427 }
428 yylval.lineno = file->lineno;
429 file->lineno++;
430 }
431
432 while (c == EOF(-1)) {
433 if (file == topfile || popfile() == EOF(-1))
434 return (EOF(-1));
435 c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget
(file->stream) : (int)(*(file->stream)->_p++)) : (getc
)(file->stream))
;
436 }
437 return (c);
438}
439
440void
441lungetc(int c)
442{
443 if (c == EOF(-1))
444 return;
445
446 if (file->ungetpos >= file->ungetsize) {
447 void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
448 if (p == NULL((void *)0))
449 err(1, "%s", __func__);
450 file->ungetbuf = p;
451 file->ungetsize *= 2;
452 }
453 file->ungetbuf[file->ungetpos++] = c;
454}
455
456int
457findeol(void)
458{
459 int c;
460
461 /* skip to either EOF or the first real EOL */
462 while (1) {
463 c = lgetc(0);
464 if (c == '\n') {
465 file->lineno++;
466 break;
467 }
468 if (c == EOF(-1))
469 break;
470 }
471 return (ERROR272);
472}
473
474int
475yylex(void)
476{
477 char buf[8096];
478 char *p, *val;
479 int quotec, next, c;
480 int token;
481
482top:
483 p = buf;
484 while ((c = lgetc(0)) == ' ' || c == '\t')
485 ; /* nothing */
486
487 yylval.lineno = file->lineno;
488 if (c == '#')
489 while ((c = lgetc(0)) != '\n' && c != EOF(-1))
490 ; /* nothing */
491 if (c == '$' && !expanding) {
492 while (1) {
493 if ((c = lgetc(0)) == EOF(-1))
494 return (0);
495
496 if (p + 1 >= buf + sizeof(buf) - 1) {
497 yyerror("string too long");
498 return (findeol());
499 }
500 if (isalnum(c) || c == '_') {
501 *p++ = c;
502 continue;
503 }
504 *p = '\0';
505 lungetc(c);
506 break;
507 }
508 val = symget(buf);
509 if (val == NULL((void *)0)) {
510 yyerror("macro '%s' not defined", buf);
511 return (findeol());
512 }
513 p = val + strlen(val) - 1;
514 lungetc(DONE_EXPAND2);
515 while (p >= val) {
516 lungetc((unsigned char)*p);
517 p--;
518 }
519 lungetc(START_EXPAND1);
520 goto top;
521 }
522
523 switch (c) {
524 case '\'':
525 case '"':
526 quotec = c;
527 while (1) {
528 if ((c = lgetc(quotec)) == EOF(-1))
529 return (0);
530 if (c == '\n') {
531 file->lineno++;
532 continue;
533 } else if (c == '\\') {
534 if ((next = lgetc(quotec)) == EOF(-1))
535 return (0);
536 if (next == quotec || next == ' ' ||
537 next == '\t')
538 c = next;
539 else if (next == '\n') {
540 file->lineno++;
541 continue;
542 } else
543 lungetc(next);
544 } else if (c == quotec) {
545 *p = '\0';
546 break;
547 } else if (c == '\0') {
548 yyerror("syntax error");
549 return (findeol());
550 }
551 if (p + 1 >= buf + sizeof(buf) - 1) {
552 yyerror("string too long");
553 return (findeol());
554 }
555 *p++ = c;
556 }
557 yylval.v.string = strdup(buf);
558 if (yylval.v.string == NULL((void *)0))
559 err(1, "%s", __func__);
560 return (STRING273);
561 }
562
563#define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' ||
x == '=')
\
564 (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
565
566 if (c == '-' || isdigit(c)) {
567 do {
568 *p++ = c;
569 if ((size_t)(p-buf) >= sizeof(buf)) {
570 yyerror("string too long");
571 return (findeol());
572 }
573 } while ((c = lgetc(0)) != EOF(-1) && isdigit(c));
574 lungetc(c);
575 if (p == buf + 1 && buf[0] == '-')
576 goto nodigits;
577 if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' ||
c == '=')
) {
578 const char *errstr = NULL((void *)0);
579
580 *p = '\0';
581 yylval.v.number = strtonum(buf, LLONG_MIN(-9223372036854775807LL -1LL),
582 LLONG_MAX9223372036854775807LL, &errstr);
583 if (errstr) {
584 yyerror("\"%s\" invalid number: %s",
585 buf, errstr);
586 return (findeol());
587 }
588 return (NUMBER274);
589 } else {
590nodigits:
591 while (p > buf + 1)
592 lungetc((unsigned char)*--p);
593 c = (unsigned char)*--p;
594 if (c == '-')
595 return (c);
596 }
597 }
598
599#define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x !=
')' && x != '{' && x != '}' && x != '!'
&& x != '=' && x != '#' && x != ',')
)
\
600 (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
601 x != '{' && x != '}' && \
602 x != '!' && x != '=' && x != '#' && \
603 x != ','))
604
605 if (isalnum(c) || c == ':' || c == '_') {
606 do {
607 *p++ = c;
608 if ((size_t)(p-buf) >= sizeof(buf)) {
609 yyerror("string too long");
610 return (findeol());
611 }
612 } while ((c = lgetc(0)) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c !=
')' && c != '{' && c != '}' && c != '!'
&& c != '=' && c != '#' && c != ',')
)
));
613 lungetc(c);
614 *p = '\0';
615 if ((token = lookup(buf)) == STRING273)
616 if ((yylval.v.string = strdup(buf)) == NULL((void *)0))
617 err(1, "%s", __func__);
618 return (token);
619 }
620 if (c == '\n') {
621 yylval.lineno = file->lineno;
622 file->lineno++;
623 }
624 if (c == EOF(-1))
625 return (0);
626 return (c);
627}
628
629struct file *
630pushfile(const char *name, int secret)
631{
632 struct file *nfile;
633
634 if ((nfile = calloc(1, sizeof(struct file))) == NULL((void *)0)) {
635 warn("%s", __func__);
636 return (NULL((void *)0));
637 }
638 if ((nfile->name = strdup(name)) == NULL((void *)0)) {
639 warn("%s", __func__);
640 free(nfile);
641 return (NULL((void *)0));
642 }
643 if ((nfile->stream = fopen(nfile->name, "r")) == NULL((void *)0)) {
644 warn("%s: %s", __func__, nfile->name);
645 free(nfile->name);
646 free(nfile);
647 return (NULL((void *)0));
648 }
649 nfile->lineno = TAILQ_EMPTY(&files)(((&files)->tqh_first) == ((void *)0)) ? 1 : 0;
650 nfile->ungetsize = 16;
651 nfile->ungetbuf = malloc(nfile->ungetsize);
652 if (nfile->ungetbuf == NULL((void *)0)) {
653 warn("%s", __func__);
654 fclose(nfile->stream);
655 free(nfile->name);
656 free(nfile);
657 return (NULL((void *)0));
658 }
659 TAILQ_INSERT_TAIL(&files, nfile, entry)do { (nfile)->entry.tqe_next = ((void *)0); (nfile)->entry
.tqe_prev = (&files)->tqh_last; *(&files)->tqh_last
= (nfile); (&files)->tqh_last = &(nfile)->entry
.tqe_next; } while (0)
;
660 return (nfile);
661}
662
663int
664popfile(void)
665{
666 struct file *prev;
667
668 if ((prev = TAILQ_PREV(file, files, entry)(*(((struct files *)((file)->entry.tqe_prev))->tqh_last
))
) != NULL((void *)0))
669 prev->errors += file->errors;
670
671 TAILQ_REMOVE(&files, file, entry)do { if (((file)->entry.tqe_next) != ((void *)0)) (file)->
entry.tqe_next->entry.tqe_prev = (file)->entry.tqe_prev
; else (&files)->tqh_last = (file)->entry.tqe_prev;
*(file)->entry.tqe_prev = (file)->entry.tqe_next; ; ; }
while (0)
;
672 fclose(file->stream);
673 free(file->name);
674 free(file->ungetbuf);
675 free(file);
676 file = prev;
677 return (file ? 0 : EOF(-1));
678}
679
680struct iscsi_config *
681parse_config(char *filename)
682{
683 struct sym *sym, *next;
684
685 file = pushfile(filename, 1);
686 if (file == NULL((void *)0))
687 return (NULL((void *)0));
688 topfile = file;
689
690 conf = calloc(1, sizeof(struct iscsi_config));
691 if (conf == NULL((void *)0))
692 return (NULL((void *)0));
693 SIMPLEQ_INIT(&conf->sessions)do { (&conf->sessions)->sqh_first = ((void *)0); (&
conf->sessions)->sqh_last = &(&conf->sessions
)->sqh_first; } while (0)
;
694
695 yyparse();
696 errors = file->errors;
697 popfile();
698
699 /* Free macros and check which have not been used. */
700 TAILQ_FOREACH_SAFE(sym, &symhead, entry, next)for ((sym) = ((&symhead)->tqh_first); (sym) != ((void *
)0) && ((next) = ((sym)->entry.tqe_next), 1); (sym
) = (next))
{
701 if (!sym->persist) {
702 free(sym->nam);
703 free(sym->val);
704 TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void *)0)) (sym)->
entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev;
else (&symhead)->tqh_last = (sym)->entry.tqe_prev;
*(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while
(0)
;
705 free(sym);
706 }
707 }
708
709 if (errors) {
710 clear_config(conf);
711 return (NULL((void *)0));
712 }
713
714 return (conf);
715}
716
717int
718cmdline_symset(char *s)
719{
720 char *sym, *val;
721 int ret;
722
723 if ((val = strrchr(s, '=')) == NULL((void *)0))
724 return (-1);
725 sym = strndup(s, val - s);
726 if (sym == NULL((void *)0))
727 errx(1, "%s: strndup", __func__);
728 ret = symset(sym, val + 1, 1);
729 free(sym);
730
731 return (ret);
732}
733
734char *
735symget(const char *nam)
736{
737 struct sym *sym;
738
739 TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void *
)0); (sym) = ((sym)->entry.tqe_next))
{
740 if (strcmp(nam, sym->nam) == 0) {
741 sym->used = 1;
742 return (sym->val);
743 }
744 }
745 return (NULL((void *)0));
746}
747
748int
749symset(const char *nam, const char *val, int persist)
750{
751 struct sym *sym;
752
753 TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void *
)0); (sym) = ((sym)->entry.tqe_next))
{
754 if (strcmp(nam, sym->nam) == 0)
755 break;
756 }
757
758 if (sym != NULL((void *)0)) {
759 if (sym->persist == 1)
760 return (0);
761 else {
762 free(sym->nam);
763 free(sym->val);
764 TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void *)0)) (sym)->
entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev;
else (&symhead)->tqh_last = (sym)->entry.tqe_prev;
*(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while
(0)
;
765 free(sym);
766 }
767 }
768 if ((sym = calloc(1, sizeof(*sym))) == NULL((void *)0))
769 return (-1);
770
771 sym->nam = strdup(nam);
772 if (sym->nam == NULL((void *)0)) {
773 free(sym);
774 return (-1);
775 }
776 sym->val = strdup(val);
777 if (sym->val == NULL((void *)0)) {
778 free(sym->nam);
779 free(sym);
780 return (-1);
781 }
782 sym->used = 0;
783 sym->persist = persist;
784 TAILQ_INSERT_TAIL(&symhead, sym, entry)do { (sym)->entry.tqe_next = ((void *)0); (sym)->entry.
tqe_prev = (&symhead)->tqh_last; *(&symhead)->tqh_last
= (sym); (&symhead)->tqh_last = &(sym)->entry.
tqe_next; } while (0)
;
785 return (0);
786}
787
788void
789clear_config(struct iscsi_config *c)
790{
791 struct session_ctlcfg *s;
792
793 while ((s = SIMPLEQ_FIRST(&c->sessions)((&c->sessions)->sqh_first))) {
794 SIMPLEQ_REMOVE_HEAD(&c->sessions, entry)do { if (((&c->sessions)->sqh_first = (&c->sessions
)->sqh_first->entry.sqe_next) == ((void *)0)) (&c->
sessions)->sqh_last = &(&c->sessions)->sqh_first
; } while (0)
;
795 free(s->session.TargetName);
796 free(s->session.InitiatorName);
797 free(s);
798 }
799
800 free(c);
801}
802#line 795 "parse.c"
803/* allocate initial stack or double stack size, up to YYMAXDEPTH */
804static int yygrowstack(void)
805{
806 unsigned int newsize;
807 long sslen;
808 short *newss;
809 YYSTYPE *newvs;
810
811 if ((newsize = yystacksize) == 0)
3
Assuming the condition is false
4
Taking false branch
812 newsize = YYINITSTACKSIZE200;
813 else if (newsize >= YYMAXDEPTH10000)
5
Assuming 'newsize' is < YYMAXDEPTH
6
Taking false branch
814 return -1;
815 else if ((newsize *= 2) > YYMAXDEPTH10000)
7
Assuming the condition is false
8
Taking false branch
816 newsize = YYMAXDEPTH10000;
817 sslen = yyssp - yyss;
818#ifdef SIZE_MAX0xffffffffffffffffUL
819#define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL
820#else
821#define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU
822#endif
823 if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss)
9
Assuming 'newsize' is 0
824 goto bail;
825 newss = (short *)realloc(yyss, newsize * sizeof *newss);
826 if (newss == NULL((void *)0))
10
Assuming 'newss' is not equal to NULL
11
Taking false branch
827 goto bail;
828 yyss = newss;
829 yyssp = newss + sslen;
830 if (newsize
11.1
'newsize' is 0
&& YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newvs)
831 goto bail;
832 newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs);
12
Memory is released
833 if (newvs == NULL((void *)0))
13
Assuming 'newvs' is equal to NULL
14
Taking true branch
834 goto bail;
15
Control jumps to line 841
835 yyvs = newvs;
836 yyvsp = newvs + sslen;
837 yystacksize = newsize;
838 yysslim = yyss + newsize - 1;
839 return 0;
840bail:
841 if (yyss
15.1
'yyss' is non-null
)
16
Taking true branch
842 free(yyss);
843 if (yyvs)
17
Assuming 'yyvs' is non-null
18
Taking true branch
844 free(yyvs);
19
Attempt to free released memory
845 yyss = yyssp = NULL((void *)0);
846 yyvs = yyvsp = NULL((void *)0);
847 yystacksize = 0;
848 return -1;
849}
850
851#define YYABORTgoto yyabort goto yyabort
852#define YYREJECTgoto yyabort goto yyabort
853#define YYACCEPTgoto yyaccept goto yyaccept
854#define YYERRORgoto yyerrlab goto yyerrlab
855int
856yyparse(void)
857{
858 int yym, yyn, yystate;
859#if YYDEBUG0
860 const char *yys;
861
862 if ((yys = getenv("YYDEBUG")))
863 {
864 yyn = *yys;
865 if (yyn >= '0' && yyn <= '9')
866 yydebug = yyn - '0';
867 }
868#endif /* YYDEBUG */
869
870 yynerrs = 0;
871 yyerrflag = 0;
872 yychar = (-1);
873
874 if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow;
1
Assuming 'yyss' is equal to NULL
2
Calling 'yygrowstack'
875 yyssp = yyss;
876 yyvsp = yyvs;
877 *yyssp = yystate = 0;
878
879yyloop:
880 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
881 if (yychar < 0)
882 {
883 if ((yychar = yylex()) < 0) yychar = 0;
884#if YYDEBUG0
885 if (yydebug)
886 {
887 yys = 0;
888 if (yychar <= YYMAXTOKEN274) yys = yyname[yychar];
889 if (!yys) yys = "illegal-symbol";
890 printf("%sdebug: state %d, reading %d (%s)\n",
891 YYPREFIX"yy", yystate, yychar, yys);
892 }
893#endif
894 }
895 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
896 yyn <= YYTABLESIZE285 && yycheck[yyn] == yychar)
897 {
898#if YYDEBUG0
899 if (yydebug)
900 printf("%sdebug: state %d, shifting to state %d\n",
901 YYPREFIX"yy", yystate, yytable[yyn]);
902#endif
903 if (yyssp >= yysslim && yygrowstack())
904 {
905 goto yyoverflow;
906 }
907 *++yyssp = yystate = yytable[yyn];
908 *++yyvsp = yylval;
909 yychar = (-1);
910 if (yyerrflag > 0) --yyerrflag;
911 goto yyloop;
912 }
913 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
914 yyn <= YYTABLESIZE285 && yycheck[yyn] == yychar)
915 {
916 yyn = yytable[yyn];
917 goto yyreduce;
918 }
919 if (yyerrflag) goto yyinrecovery;
920#if defined(__GNUC__4)
921 goto yynewerror;
922#endif
923yynewerror:
924 yyerror("syntax error");
925#if defined(__GNUC__4)
926 goto yyerrlab;
927#endif
928yyerrlab:
929 ++yynerrs;
930yyinrecovery:
931 if (yyerrflag < 3)
932 {
933 yyerrflag = 3;
934 for (;;)
935 {
936 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 &&
937 yyn <= YYTABLESIZE285 && yycheck[yyn] == YYERRCODE256)
938 {
939#if YYDEBUG0
940 if (yydebug)
941 printf("%sdebug: state %d, error recovery shifting\
942 to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]);
943#endif
944 if (yyssp >= yysslim && yygrowstack())
945 {
946 goto yyoverflow;
947 }
948 *++yyssp = yystate = yytable[yyn];
949 *++yyvsp = yylval;
950 goto yyloop;
951 }
952 else
953 {
954#if YYDEBUG0
955 if (yydebug)
956 printf("%sdebug: error recovery discarding state %d\n",
957 YYPREFIX"yy", *yyssp);
958#endif
959 if (yyssp <= yyss) goto yyabort;
960 --yyssp;
961 --yyvsp;
962 }
963 }
964 }
965 else
966 {
967 if (yychar == 0) goto yyabort;
968#if YYDEBUG0
969 if (yydebug)
970 {
971 yys = 0;
972 if (yychar <= YYMAXTOKEN274) yys = yyname[yychar];
973 if (!yys) yys = "illegal-symbol";
974 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
975 YYPREFIX"yy", yystate, yychar, yys);
976 }
977#endif
978 yychar = (-1);
979 goto yyloop;
980 }
981yyreduce:
982#if YYDEBUG0
983 if (yydebug)
984 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
985 YYPREFIX"yy", yystate, yyn, yyrule[yyn]);
986#endif
987 yym = yylen[yyn];
988 if (yym)
989 yyval = yyvsp[1-yym];
990 else
991 memset(&yyval, 0, sizeof yyval);
992 switch (yyn)
993 {
994case 7:
995#line 131 "/usr/src/usr.sbin/iscsictl/parse.y"
996{ file->errors++; }
997break;
998case 8:
999#line 134 "/usr/src/usr.sbin/iscsictl/parse.y"
1000{
1001 struct file *nfile;
1002
1003 if ((nfile = pushfile(yyvsp[0].v.string, 1)) == NULL((void *)0)) {
1004 yyerror("failed to include file %s", yyvsp[0].v.string);
1005 free(yyvsp[0].v.string);
1006 YYERRORgoto yyerrlab;
1007 }
1008 free(yyvsp[0].v.string);
1009
1010 file = nfile;
1011 lungetc('\n');
1012 }
1013break;
1014case 9:
1015#line 149 "/usr/src/usr.sbin/iscsictl/parse.y"
1016{
1017 if (asprintf(&yyval.v.string, "%s %s", yyvsp[-1].v.string, yyvsp[0].v.string) == -1) {
1018 free(yyvsp[-1].v.string);
1019 free(yyvsp[0].v.string);
1020 yyerror("string: asprintf");
1021 YYERRORgoto yyerrlab;
1022 }
1023 free(yyvsp[-1].v.string);
1024 free(yyvsp[0].v.string);
1025 }
1026break;
1027case 11:
1028#line 162 "/usr/src/usr.sbin/iscsictl/parse.y"
1029{
1030 char *s = yyvsp[-2].v.string;
1031 while (*s++) {
1032 if (isspace((unsigned char)*s)) {
1033 yyerror("macro name cannot contain "
1034 "whitespace");
1035 free(yyvsp[-2].v.string);
1036 free(yyvsp[0].v.string);
1037 YYERRORgoto yyerrlab;
1038 }
1039 }
1040 if (symset(yyvsp[-2].v.string, yyvsp[0].v.string, 0) == -1)
1041 err(1, "cannot store variable");
1042 free(yyvsp[-2].v.string);
1043 free(yyvsp[0].v.string);
1044 }
1045break;
1046case 15:
1047#line 187 "/usr/src/usr.sbin/iscsictl/parse.y"
1048{
1049 u_int32_t mask1, mask2;
1050
1051 if (!strcasecmp(yyvsp[-2].v.string, "oui")) {
1052 conf->initiator.isid_base = ISCSI_ISID_OUI0x00000000;
1053 mask1 = 0x3fffff00;
1054 mask2 = 0x000000ff;
1055 } else if (!strcasecmp(yyvsp[-2].v.string, "en")) {
1056 conf->initiator.isid_base = ISCSI_ISID_EN0x40000000;
1057 mask1 = 0x00ffffff;
1058 mask2 = 0;
1059 } else if (!strcasecmp(yyvsp[-2].v.string, "rand")) {
1060 conf->initiator.isid_base = ISCSI_ISID_RAND0x80000000;
1061 mask1 = 0x00ffffff;
1062 mask2 = 0;
1063 } else {
1064 yyerror("isid type %s unknown", yyvsp[-2].v.string);
1065 free(yyvsp[-2].v.string);
1066 YYERRORgoto yyerrlab;
1067 }
1068 free(yyvsp[-2].v.string);
1069 conf->initiator.isid_base |= yyvsp[-1].v.number & mask1;
1070 conf->initiator.isid_base |= (yyvsp[0].v.number >> 16) & mask2;
1071 conf->initiator.isid_qual = yyvsp[0].v.number;
1072 }
1073break;
1074case 16:
1075#line 214 "/usr/src/usr.sbin/iscsictl/parse.y"
1076{
1077 struct session_ctlcfg *scelm;
1078
1079 scelm = calloc(1, sizeof(*scelm));
1080 session = &scelm->session;
1081 if (strlcpy(session->SessionName, yyvsp[0].v.string,
1082 sizeof(session->SessionName)) >=
1083 sizeof(session->SessionName)) {
1084 yyerror("target name \"%s\" too long", yyvsp[0].v.string);
1085 free(yyvsp[0].v.string);
1086 free(scelm);
1087 YYERRORgoto yyerrlab;
1088 }
1089 free(yyvsp[0].v.string);
1090 SIMPLEQ_INSERT_TAIL(&conf->sessions, scelm, entry)do { (scelm)->entry.sqe_next = ((void *)0); *(&conf->
sessions)->sqh_last = (scelm); (&conf->sessions)->
sqh_last = &(scelm)->entry.sqe_next; } while (0)
;
1091 }
1092break;
1093case 20:
1094#line 236 "/usr/src/usr.sbin/iscsictl/parse.y"
1095{ session->disabled = yyvsp[0].v.i; }
1096break;
1097case 21:
1098#line 237 "/usr/src/usr.sbin/iscsictl/parse.y"
1099{ session->SessionType = yyvsp[0].v.i; }
1100break;
1101case 22:
1102#line 238 "/usr/src/usr.sbin/iscsictl/parse.y"
1103{ session->TargetName = yyvsp[0].v.string; }
1104break;
1105case 23:
1106#line 239 "/usr/src/usr.sbin/iscsictl/parse.y"
1107{ session->InitiatorName = yyvsp[0].v.string; }
1108break;
1109case 24:
1110#line 240 "/usr/src/usr.sbin/iscsictl/parse.y"
1111{
1112 bcopy(yyvsp[0].v.addrinfo->ai_addr, &session->connection.TargetAddr,
1113 yyvsp[0].v.addrinfo->ai_addr->sa_len);
1114 freeaddrinfo(yyvsp[0].v.addrinfo);
1115 }
1116break;
1117case 25:
1118#line 245 "/usr/src/usr.sbin/iscsictl/parse.y"
1119{
1120 ((struct sockaddr_in *)yyvsp[0].v.addrinfo->ai_addr)->sin_port = 0;
1121 bcopy(yyvsp[0].v.addrinfo->ai_addr, &session->connection.LocalAddr,
1122 yyvsp[0].v.addrinfo->ai_addr->sa_len);
1123 freeaddrinfo(yyvsp[0].v.addrinfo);
1124 }
1125break;
1126case 26:
1127#line 253 "/usr/src/usr.sbin/iscsictl/parse.y"
1128{
1129 struct addrinfo hints;
1130 char *hostname;
1131 int error;
1132
1133 yyval.v.addrinfo = NULL((void *)0);
1134
1135 if (yyvsp[0].v.addrinfo_opts.port == NULL((void *)0)) {
1136 if ((yyvsp[0].v.addrinfo_opts.port = strdup("iscsi")) == NULL((void *)0)) {
1137 free(yyvsp[-1].v.string);
1138 yyerror("port strdup");
1139 YYERRORgoto yyerrlab;
1140 }
1141 }
1142
1143 memset(&hints, 0, sizeof(hints));
1144 hints.ai_family = yyvsp[0].v.addrinfo_opts.af;
1145 hints.ai_socktype = SOCK_STREAM1;
1146 hints.ai_protocol = IPPROTO_TCP6;
1147
1148 if (strcmp(yyvsp[-1].v.string, "*") == 0) {
1149 hostname = NULL((void *)0);
1150 hints.ai_flags = AI_PASSIVE1;
1151 } else
1152 hostname = yyvsp[-1].v.string;
1153
1154 error = getaddrinfo(hostname, yyvsp[0].v.addrinfo_opts.port, &hints, &yyval.v.addrinfo);
1155 if (error) {
1156 yyerror("%s (%s %s)", gai_strerror(error),
1157 yyvsp[-1].v.string, yyvsp[0].v.addrinfo_opts.port);
1158 free(yyvsp[-1].v.string);
1159 free(yyvsp[0].v.addrinfo_opts.port);
1160 YYERRORgoto yyerrlab;
1161 }
1162
1163 free(yyvsp[-1].v.string);
1164 free(yyvsp[0].v.addrinfo_opts.port);
1165 }
1166break;
1167case 27:
1168#line 293 "/usr/src/usr.sbin/iscsictl/parse.y"
1169{
1170 addrinfo_opts.port = NULL((void *)0);
1171 addrinfo_opts.af = PF_UNSPEC0;
1172 }
1173break;
1174case 28:
1175#line 297 "/usr/src/usr.sbin/iscsictl/parse.y"
1176{ yyval.v.addrinfo_opts = addrinfo_opts; }
1177break;
1178case 29:
1179#line 298 "/usr/src/usr.sbin/iscsictl/parse.y"
1180{
1181 addrinfo_opts.port = NULL((void *)0);
1182 addrinfo_opts.af = PF_UNSPEC0;
1183 yyval.v.addrinfo_opts = addrinfo_opts;
1184 }
1185break;
1186case 32:
1187#line 309 "/usr/src/usr.sbin/iscsictl/parse.y"
1188{
1189 if (addrinfo_opts.port != NULL((void *)0)) {
1190 yyerror("port cannot be redefined");
1191 YYERRORgoto yyerrlab;
1192 }
1193 addrinfo_opts.port = yyvsp[0].v.string;
1194 }
1195break;
1196case 33:
1197#line 316 "/usr/src/usr.sbin/iscsictl/parse.y"
1198{
1199 if (addrinfo_opts.af != PF_UNSPEC0) {
1200 yyerror("address family cannot be redefined");
1201 YYERRORgoto yyerrlab;
1202 }
1203 addrinfo_opts.af = yyvsp[0].v.i;
1204 }
1205break;
1206case 34:
1207#line 325 "/usr/src/usr.sbin/iscsictl/parse.y"
1208{ yyval.v.string = yyvsp[0].v.string; }
1209break;
1210case 35:
1211#line 328 "/usr/src/usr.sbin/iscsictl/parse.y"
1212{ yyval.v.i = PF_INET2; }
1213break;
1214case 36:
1215#line 329 "/usr/src/usr.sbin/iscsictl/parse.y"
1216{ yyval.v.i = PF_INET624; }
1217break;
1218case 37:
1219#line 332 "/usr/src/usr.sbin/iscsictl/parse.y"
1220{ yyval.v.i = 0; }
1221break;
1222case 38:
1223#line 333 "/usr/src/usr.sbin/iscsictl/parse.y"
1224{ yyval.v.i = 1; }
1225break;
1226case 39:
1227#line 336 "/usr/src/usr.sbin/iscsictl/parse.y"
1228{ yyval.v.i = SESSION_TYPE_NORMAL0; }
1229break;
1230case 40:
1231#line 337 "/usr/src/usr.sbin/iscsictl/parse.y"
1232{ yyval.v.i = SESSION_TYPE_DISCOVERY1; }
1233break;
1234#line 1227 "parse.c"
1235 }
1236 yyssp -= yym;
1237 yystate = *yyssp;
1238 yyvsp -= yym;
1239 yym = yylhs[yyn];
1240 if (yystate == 0 && yym == 0)
1241 {
1242#if YYDEBUG0
1243 if (yydebug)
1244 printf("%sdebug: after reduction, shifting from state 0 to\
1245 state %d\n", YYPREFIX"yy", YYFINAL1);
1246#endif
1247 yystate = YYFINAL1;
1248 *++yyssp = YYFINAL1;
1249 *++yyvsp = yyval;
1250 if (yychar < 0)
1251 {
1252 if ((yychar = yylex()) < 0) yychar = 0;
1253#if YYDEBUG0
1254 if (yydebug)
1255 {
1256 yys = 0;
1257 if (yychar <= YYMAXTOKEN274) yys = yyname[yychar];
1258 if (!yys) yys = "illegal-symbol";
1259 printf("%sdebug: state %d, reading %d (%s)\n",
1260 YYPREFIX"yy", YYFINAL1, yychar, yys);
1261 }
1262#endif
1263 }
1264 if (yychar == 0) goto yyaccept;
1265 goto yyloop;
1266 }
1267 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1268 yyn <= YYTABLESIZE285 && yycheck[yyn] == yystate)
1269 yystate = yytable[yyn];
1270 else
1271 yystate = yydgoto[yym];
1272#if YYDEBUG0
1273 if (yydebug)
1274 printf("%sdebug: after reduction, shifting from state %d \
1275to state %d\n", YYPREFIX"yy", *yyssp, yystate);
1276#endif
1277 if (yyssp >= yysslim && yygrowstack())
1278 {
1279 goto yyoverflow;
1280 }
1281 *++yyssp = yystate;
1282 *++yyvsp = yyval;
1283 goto yyloop;
1284yyoverflow:
1285 yyerror("yacc stack overflow");
1286yyabort:
1287 if (yyss)
1288 free(yyss);
1289 if (yyvs)
1290 free(yyvs);
1291 yyss = yyssp = NULL((void *)0);
1292 yyvs = yyvsp = NULL((void *)0);
1293 yystacksize = 0;
1294 return (1);
1295yyaccept:
1296 if (yyss)
1297 free(yyss);
1298 if (yyvs)
1299 free(yyvs);
1300 yyss = yyssp = NULL((void *)0);
1301 yyvs = yyvsp = NULL((void *)0);
1302 yystacksize = 0;
1303 return (0);
1304}