Coverage Report

Created: 2023-06-07 06:53

/src/libfvde/libfplist/libfplist_xml_parser.c
Line
Count
Source (jump to first uncovered line)
1
/* original parser id follows */
2
/* yysccsid[] = "@(#)yaccpar  1.9 (Berkeley) 02/21/93" */
3
/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4
5
#define YYBYACC 1
6
#define YYMAJOR 1
7
#define YYMINOR 9
8
#define YYPATCH 20140715
9
10
1.53M
#define YYEMPTY        (-1)
11
#define yyclearin      (yychar = YYEMPTY)
12
#define yyerrok        (yyerrflag = 0)
13
#define YYRECOVERING() (yyerrflag != 0)
14
20
#define YYENOMEM       (-2)
15
1.40k
#define YYEOF          0
16
17
#ifndef yyparse
18
#define yyparse    xml_scanner_parse
19
#endif /* yyparse */
20
21
#ifndef yylex
22
1.53M
#define yylex      xml_scanner_lex
23
#endif /* yylex */
24
25
#ifndef yyerror
26
698
#define yyerror    xml_scanner_error
27
#endif /* yyerror */
28
29
#ifndef yychar
30
10.7M
#define yychar     xml_scanner_char
31
#endif /* yychar */
32
33
#ifndef yyval
34
6.03M
#define yyval      xml_scanner_val
35
#endif /* yyval */
36
37
#ifndef yylval
38
1.53M
#define yylval     xml_scanner_lval
39
#endif /* yylval */
40
41
#ifndef yydebug
42
#define yydebug    xml_scanner_debug
43
#endif /* yydebug */
44
45
#ifndef yynerrs
46
3.03k
#define yynerrs    xml_scanner_nerrs
47
#endif /* yynerrs */
48
49
#ifndef yyerrflag
50
1.53M
#define yyerrflag  xml_scanner_errflag
51
#endif /* yyerrflag */
52
53
#ifndef yylhs
54
2.71M
#define yylhs      xml_scanner_lhs
55
#endif /* yylhs */
56
57
#ifndef yylen
58
2.71M
#define yylen      xml_scanner_len
59
#endif /* yylen */
60
61
#ifndef yydefred
62
4.24M
#define yydefred   xml_scanner_defred
63
#endif /* yydefred */
64
65
#ifndef yydgoto
66
1.68M
#define yydgoto    xml_scanner_dgoto
67
#endif /* yydgoto */
68
69
#ifndef yysindex
70
2.42M
#define yysindex   xml_scanner_sindex
71
#endif /* yysindex */
72
73
#ifndef yyrindex
74
613k
#define yyrindex   xml_scanner_rindex
75
#endif /* yyrindex */
76
77
#ifndef yygindex
78
2.71M
#define yygindex   xml_scanner_gindex
79
#endif /* yygindex */
80
81
#ifndef yytable
82
4.70M
#define yytable    xml_scanner_table
83
#endif /* yytable */
84
85
#ifndef yycheck
86
3.79M
#define yycheck    xml_scanner_check
87
#endif /* yycheck */
88
89
#ifndef yyname
90
#define yyname     xml_scanner_name
91
#endif /* yyname */
92
93
#ifndef yyrule
94
#define yyrule     xml_scanner_rule
95
#endif /* yyrule */
96
#define YYPREFIX "xml_scanner_"
97
98
#define YYPURE 0
99
100
/*
101
 * XML parser functions
102
 *
103
 * Copyright (C) 2016-2022, Joachim Metz <joachim.metz@gmail.com>
104
 *
105
 * Refer to AUTHORS for acknowledgements.
106
 *
107
 * This program is free software: you can redistribute it and/or modify
108
 * it under the terms of the GNU Lesser General Public License as published by
109
 * the Free Software Foundation, either version 3 of the License, or
110
 * (at your option) any later version.
111
 *
112
 * This program is distributed in the hope that it will be useful,
113
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
114
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
115
 * GNU General Public License for more details.
116
 *
117
 * You should have received a copy of the GNU Lesser General Public License
118
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
119
 */
120
121
#include <common.h>
122
#include <memory.h>
123
#include <narrow_string.h>
124
#include <types.h>
125
126
#if defined( HAVE_STDLIB_H ) || defined( WINAPI )
127
#include <stdlib.h>
128
#endif
129
130
#include "libfplist_libcerror.h"
131
#include "libfplist_libcnotify.h"
132
#include "libfplist_property_list.h"
133
#include "libfplist_types.h"
134
#include "libfplist_xml_tag.h"
135
136
#define YYMALLOC  xml_scanner_alloc
137
#define YYREALLOC xml_scanner_realloc
138
#define YYFREE    xml_scanner_free
139
140
1.53M
#define YYLEX_PARAM NULL
141
#define YYPARSE_PARAM parser_state
142
143
#if defined( HAVE_DEBUG_OUTPUT )
144
#define xml_parser_rule_print( string ) \
145
  if( libcnotify_verbose != 0 ) libcnotify_printf( "xml_parser: rule: %s\n", string )
146
#else
147
#define xml_parser_rule_print( string )
148
#endif
149
150
#ifdef YYSTYPE
151
#undef  YYSTYPE_IS_DECLARED
152
#define YYSTYPE_IS_DECLARED 1
153
#endif
154
#ifndef YYSTYPE_IS_DECLARED
155
#define YYSTYPE_IS_DECLARED 1
156
typedef union
157
{
158
        /* The numeric value
159
         */
160
        uint32_t numeric_value;
161
162
        /* The string value
163
         */
164
  struct xml_plist_string_value
165
  {
166
    /* The string data
167
     */
168
          const char *data;
169
170
    /* The string length
171
     */
172
    size_t length;
173
174
  } string_value;
175
} YYSTYPE;
176
#endif /* !YYSTYPE_IS_DECLARED */
177
178
typedef struct xml_parser_state xml_parser_state_t;
179
180
struct xml_parser_state
181
{
182
  /* The property list
183
   */
184
  libfplist_property_list_t *property_list;
185
186
  /* The error
187
   */
188
  libcerror_error_t **error;
189
190
  /* The root XML tag
191
   */
192
  libfplist_xml_tag_t *root_tag;
193
194
  /* The current XML tag
195
   */
196
  libfplist_xml_tag_t *current_tag;
197
198
  /* The parent XML tag
199
   */
200
  libfplist_xml_tag_t *parent_tag;
201
};
202
203
typedef size_t yy_size_t;
204
typedef struct yy_buffer_state* YY_BUFFER_STATE;
205
206
extern \
207
int xml_scanner_suppress_error;
208
209
extern \
210
int xml_scanner_lex_destroy(
211
     void );
212
213
extern \
214
void *xml_scanner_alloc(
215
       yy_size_t size );
216
217
extern \
218
void *xml_scanner_realloc(
219
       void *buffer,
220
       yy_size_t size );
221
222
extern \
223
void *xml_scanner_free(
224
       void *buffer );
225
226
extern \
227
int xml_scanner_lex(
228
     void *user_data );
229
230
extern \
231
void xml_scanner_error(
232
      void *parser_state,
233
      const char *error_string );
234
235
extern \
236
YY_BUFFER_STATE xml_scanner__scan_buffer(
237
                 char *buffer,
238
                 yy_size_t buffer_size );
239
240
extern \
241
void xml_scanner__delete_buffer(
242
      YY_BUFFER_STATE buffer_state );
243
244
extern \
245
size_t xml_scanner_buffer_offset;
246
247
static char *xml_parser_function = "xml_parser";
248
249
int xml_parser_parse_buffer(
250
     libfplist_property_list_t *property_list,
251
     uint8_t *buffer,
252
     size_t buffer_size,
253
     libcerror_error_t **error );
254
255
256
/* compatibility with bison */
257
#ifdef YYPARSE_PARAM
258
/* compatibility with FreeBSD */
259
# ifdef YYPARSE_PARAM_TYPE
260
#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
261
# else
262
#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
263
# endif
264
#else
265
# define YYPARSE_DECL() yyparse(void * parser_state)
266
#endif
267
268
/* Parameters sent to lex. */
269
#ifdef YYLEX_PARAM
270
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
271
1.53M
# define YYLEX yylex(YYLEX_PARAM)
272
#else
273
# define YYLEX_DECL() yylex((void *)  NULL)
274
# define YYLEX yylex(NULL)
275
#endif
276
277
/* Parameters sent to yyerror. */
278
#ifndef YYERROR_DECL
279
#define YYERROR_DECL() yyerror(void * parser_state, const char *s)
280
#endif
281
#ifndef YYERROR_CALL
282
698
#define YYERROR_CALL(msg) yyerror(parser_state, msg)
283
#endif
284
285
extern int YYPARSE_DECL();
286
287
#define XML_ATTRIBUTE_ASSIGN 257
288
#define XML_COMMENT 258
289
#define XML_DOCTYPE 259
290
#define XML_PROLOGUE 260
291
#define XML_TAG_END 261
292
#define XML_TAG_END_SINGLE 262
293
#define XML_UNDEFINED 263
294
#define XML_ATTRIBUTE_NAME 264
295
#define XML_ATTRIBUTE_VALUE 265
296
#define XML_TAG_CLOSE 266
297
#define XML_TAG_CONTENT 267
298
#define XML_TAG_OPEN_START 268
299
286k
#define YYERRCODE 256
300
typedef short YYINT;
301
static const YYINT xml_scanner_lhs[] = {                 -1,
302
    0,    1,    1,    2,    2,    4,    4,    6,    6,    6,
303
    9,    3,    8,    5,    7,   10,   10,   11,
304
};
305
static const YYINT xml_scanner_len[] = {                  2,
306
    5,    0,    1,    0,    1,    0,    2,    3,    3,    1,
307
    1,    3,    3,    1,    1,    0,    2,    3,
308
};
309
static const YYINT xml_scanner_defred[] = {               0,
310
    3,    0,    0,    5,    0,   11,    0,    0,    0,    0,
311
    0,   10,    0,    0,    0,    0,   15,    0,    0,   14,
312
    1,    7,    0,    0,   12,   17,    8,    9,   13,   18,
313
};
314
static const YYINT xml_scanner_dgoto[] = {                2,
315
    3,    5,    9,   10,   21,   11,   19,   12,   13,   15,
316
   16,
317
};
318
static const YYINT xml_scanner_sindex[] = {            -258,
319
    0,    0, -243,    0, -260,    0, -260, -247, -261, -248,
320
 -260,    0, -247, -238, -241, -247,    0, -248, -248,    0,
321
    0,    0, -251, -244,    0,    0,    0,    0,    0,    0,
322
};
323
static const YYINT xml_scanner_rindex[] = {            -259,
324
    0,    0, -246,    0,    0,    0, -242, -236, -242,    0,
325
 -242,    0, -249,    0,    0, -249,    0,    0,    0,    0,
326
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
327
};
328
static const YYINT xml_scanner_gindex[] = {               0,
329
    0,    0,   18,   -6,   -4,    0,    0,    0,   21,  -12,
330
    0,
331
};
332
10.5M
#define YYTABLESIZE 26
333
static const YYINT xml_scanner_table[] = {                2,
334
   23,    1,   18,   26,   22,   17,    6,    6,    2,   25,
335
   29,   16,   16,   27,   28,    4,   14,   20,   24,   25,
336
   30,    4,    7,    6,   16,    8,
337
};
338
static const YYINT xml_scanner_check[] = {              259,
339
   13,  260,    9,   16,   11,  267,  268,  268,  268,  261,
340
  262,  261,  262,   18,   19,  259,  264,  266,  257,  261,
341
  265,  268,    5,  266,  261,    5,
342
};
343
2.80k
#define YYFINAL 2
344
#ifndef YYDEBUG
345
#define YYDEBUG 0
346
#endif
347
#define YYMAXTOKEN 268
348
#define YYUNDFTOKEN 282
349
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
350
#if YYDEBUG
351
static const char *const xml_scanner_name[] = {
352
353
"end-of-file",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,
354
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,0,
355
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,0,
356
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,0,
357
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,0,
358
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,0,
359
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"XML_ATTRIBUTE_ASSIGN",
360
"XML_COMMENT","XML_DOCTYPE","XML_PROLOGUE","XML_TAG_END","XML_TAG_END_SINGLE",
361
"XML_UNDEFINED","XML_ATTRIBUTE_NAME","XML_ATTRIBUTE_VALUE","XML_TAG_CLOSE",
362
"XML_TAG_CONTENT","XML_TAG_OPEN_START",0,0,0,0,0,0,0,0,0,0,0,0,0,
363
"illegal-symbol",
364
};
365
static const char *const xml_scanner_rule[] = {
366
"$accept : xml_plist_main",
367
"xml_plist_main : xml_prologue xml_doctype xml_tag_open xml_tags xml_tag_close",
368
"xml_prologue :",
369
"xml_prologue : XML_PROLOGUE",
370
"xml_doctype :",
371
"xml_doctype : XML_DOCTYPE",
372
"xml_tags :",
373
"xml_tags : xml_tag xml_tags",
374
"xml_tag : xml_tag_open xml_tags xml_tag_close",
375
"xml_tag : xml_tag_open xml_tag_content xml_tag_close",
376
"xml_tag : xml_tag_single",
377
"xml_tag_open_start : XML_TAG_OPEN_START",
378
"xml_tag_open : xml_tag_open_start xml_attributes XML_TAG_END",
379
"xml_tag_single : xml_tag_open_start xml_attributes XML_TAG_END_SINGLE",
380
"xml_tag_close : XML_TAG_CLOSE",
381
"xml_tag_content : XML_TAG_CONTENT",
382
"xml_attributes :",
383
"xml_attributes : xml_attribute xml_attributes",
384
"xml_attribute : XML_ATTRIBUTE_NAME XML_ATTRIBUTE_ASSIGN XML_ATTRIBUTE_VALUE",
385
386
};
387
#endif
388
389
int      yydebug;
390
int      yynerrs;
391
392
int      yyerrflag;
393
int      yychar;
394
YYSTYPE  yyval;
395
YYSTYPE  yylval;
396
397
/* define the initial stack-sizes */
398
#ifdef YYSTACKSIZE
399
#undef YYMAXDEPTH
400
#define YYMAXDEPTH  YYSTACKSIZE
401
#else
402
#ifdef YYMAXDEPTH
403
#define YYSTACKSIZE YYMAXDEPTH
404
#else
405
#define YYSTACKSIZE 10000
406
56
#define YYMAXDEPTH  10000
407
#endif
408
#endif
409
410
4
#define YYINITSTACKSIZE 200
411
412
typedef struct {
413
    unsigned stacksize;
414
    YYINT    *s_base;
415
    YYINT    *s_mark;
416
    YYINT    *s_last;
417
    YYSTYPE  *l_base;
418
    YYSTYPE  *l_mark;
419
} YYSTACKDATA;
420
/* variables for the parser stack */
421
static YYSTACKDATA yystack;
422
423
int xml_parser_parse_buffer(
424
     libfplist_property_list_t *property_list,
425
     uint8_t *buffer,
426
     size_t buffer_size,
427
     libcerror_error_t **error )
428
2.33k
{
429
2.33k
  xml_parser_state_t parser_state;
430
  
431
2.33k
  YY_BUFFER_STATE buffer_state = NULL;
432
2.33k
  static char *function        = "xml_parser_parse_buffer";
433
2.33k
  int result                   = -1;
434
435
2.33k
  buffer_state = xml_scanner__scan_buffer(
436
2.33k
                  (char *) buffer,
437
2.33k
                  buffer_size );
438
439
2.33k
  xml_scanner_buffer_offset = 0;
440
441
2.33k
  if( buffer_state != NULL )
442
2.33k
  {
443
2.33k
    parser_state.property_list = property_list;
444
2.33k
    parser_state.error         = error;
445
2.33k
    parser_state.root_tag      = NULL;
446
2.33k
    parser_state.current_tag   = NULL;
447
2.33k
    parser_state.parent_tag    = NULL;
448
449
2.33k
    if( xml_scanner_parse(
450
2.33k
         &parser_state ) == 0 )
451
1.38k
    {
452
1.38k
      if( libfplist_property_list_set_root_tag(
453
1.38k
           property_list,
454
1.38k
           parser_state.root_tag,
455
1.38k
           error ) != 1 )
456
0
      {
457
0
        libcerror_error_set(
458
0
         error,
459
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
460
0
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
461
0
         "%s: unable to set root tag.",
462
0
         function );
463
464
0
        result = -1;
465
0
      }
466
1.38k
      else
467
1.38k
      {
468
1.38k
        parser_state.root_tag = NULL;
469
470
1.38k
        result = 1;
471
1.38k
      }
472
1.38k
    }
473
2.33k
    xml_scanner__delete_buffer(
474
2.33k
     buffer_state );
475
2.33k
  }
476
2.33k
  xml_scanner_lex_destroy();
477
478
2.33k
  if( parser_state.root_tag != NULL )
479
790
  {
480
790
    libfplist_xml_tag_free(
481
790
     &( parser_state.root_tag ),
482
790
     NULL );
483
790
  }
484
2.33k
  return( result );
485
2.33k
}
486
487
488
#if YYDEBUG
489
#include <stdio.h>    /* needed for printf */
490
#endif
491
492
#include <stdlib.h> /* needed for malloc, etc */
493
#include <string.h> /* needed for memset */
494
495
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
496
static int yygrowstack(YYSTACKDATA *data)
497
32
{
498
32
    int i;
499
32
    unsigned newsize;
500
32
    YYINT *newss;
501
32
    YYSTYPE *newvs;
502
503
32
    if ((newsize = data->stacksize) == 0)
504
4
        newsize = YYINITSTACKSIZE;
505
28
    else if (newsize >= YYMAXDEPTH)
506
4
        return YYENOMEM;
507
24
    else if ((newsize *= 2) > YYMAXDEPTH)
508
4
        newsize = YYMAXDEPTH;
509
510
28
    i = (int) (data->s_mark - data->s_base);
511
28
    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
512
28
    if (newss == 0)
513
0
        return YYENOMEM;
514
515
28
    data->s_base = newss;
516
28
    data->s_mark = newss + i;
517
518
28
    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
519
28
    if (newvs == 0)
520
0
        return YYENOMEM;
521
522
28
    data->l_base = newvs;
523
28
    data->l_mark = newvs + i;
524
525
28
    data->stacksize = newsize;
526
28
    data->s_last = data->s_base + newsize - 1;
527
28
    return 0;
528
28
}
529
530
#if YYPURE || defined(YY_NO_LEAKS)
531
static void yyfreestack(YYSTACKDATA *data)
532
{
533
    free(data->s_base);
534
    free(data->l_base);
535
    memset(data, 0, sizeof(*data));
536
}
537
#else
538
#define yyfreestack(data) /* nothing */
539
#endif
540
541
257
#define YYABORT  goto yyabort
542
#define YYREJECT goto yyabort
543
#define YYACCEPT goto yyaccept
544
#define YYERROR  goto yyerrlab
545
546
int
547
YYPARSE_DECL()
548
2.33k
{
549
2.33k
    int yym, yyn, yystate;
550
#if YYDEBUG
551
    const char *yys;
552
553
    if ((yys = getenv("YYDEBUG")) != 0)
554
    {
555
        yyn = *yys;
556
        if (yyn >= '0' && yyn <= '9')
557
            yydebug = yyn - '0';
558
    }
559
#endif
560
561
2.33k
    yynerrs = 0;
562
2.33k
    yyerrflag = 0;
563
2.33k
    yychar = YYEMPTY;
564
2.33k
    yystate = 0;
565
566
#if YYPURE
567
    memset(&yystack, 0, sizeof(yystack));
568
#endif
569
570
2.33k
    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
571
2.33k
    yystack.s_mark = yystack.s_base;
572
2.33k
    yystack.l_mark = yystack.l_base;
573
2.33k
    yystate = 0;
574
2.33k
    *yystack.s_mark = 0;
575
576
4.24M
yyloop:
577
4.24M
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
578
2.14M
    if (yychar < 0)
579
1.53M
    {
580
1.53M
        if ((yychar = YYLEX) < 0) yychar = YYEOF;
581
#if YYDEBUG
582
        if (yydebug)
583
        {
584
            yys = yyname[YYTRANSLATE(yychar)];
585
            printf("%sdebug: state %d, reading %d (%s)\n",
586
                    YYPREFIX, yystate, yychar, yys);
587
        }
588
#endif
589
1.53M
    }
590
2.14M
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
591
2.14M
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
592
1.53M
    {
593
#if YYDEBUG
594
        if (yydebug)
595
            printf("%sdebug: state %d, shifting to state %d\n",
596
                    YYPREFIX, yystate, yytable[yyn]);
597
#endif
598
1.53M
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
599
2
        {
600
2
            goto yyoverflow;
601
2
        }
602
1.53M
        yystate = yytable[yyn];
603
1.53M
        *++yystack.s_mark = yytable[yyn];
604
1.53M
        *++yystack.l_mark = yylval;
605
1.53M
        yychar = YYEMPTY;
606
1.53M
        if (yyerrflag > 0)  --yyerrflag;
607
1.53M
        goto yyloop;
608
1.53M
    }
609
613k
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
610
613k
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
611
613k
    {
612
613k
        yyn = yytable[yyn];
613
613k
        goto yyreduce;
614
613k
    }
615
696
    if (yyerrflag) goto yyinrecovery;
616
617
696
    YYERROR_CALL("syntax error");
618
619
696
    goto yyerrlab;
620
621
696
yyerrlab:
622
696
    ++yynerrs;
623
624
696
yyinrecovery:
625
696
    if (yyerrflag < 3)
626
696
    {
627
696
        yyerrflag = 3;
628
696
        for (;;)
629
284k
        {
630
284k
            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
631
284k
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
632
0
            {
633
#if YYDEBUG
634
                if (yydebug)
635
                    printf("%sdebug: state %d, error recovery shifting\
636
 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
637
#endif
638
0
                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
639
0
                {
640
0
                    goto yyoverflow;
641
0
                }
642
0
                yystate = yytable[yyn];
643
0
                *++yystack.s_mark = yytable[yyn];
644
0
                *++yystack.l_mark = yylval;
645
0
                goto yyloop;
646
0
            }
647
284k
            else
648
284k
            {
649
#if YYDEBUG
650
                if (yydebug)
651
                    printf("%sdebug: error recovery discarding state %d\n",
652
                            YYPREFIX, *yystack.s_mark);
653
#endif
654
284k
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
655
283k
                --yystack.s_mark;
656
283k
                --yystack.l_mark;
657
283k
            }
658
284k
        }
659
696
    }
660
0
    else
661
0
    {
662
0
        if (yychar == YYEOF) goto yyabort;
663
#if YYDEBUG
664
        if (yydebug)
665
        {
666
            yys = yyname[YYTRANSLATE(yychar)];
667
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
668
                    YYPREFIX, yystate, yychar, yys);
669
        }
670
#endif
671
0
        yychar = YYEMPTY;
672
0
        goto yyloop;
673
0
    }
674
675
2.71M
yyreduce:
676
#if YYDEBUG
677
    if (yydebug)
678
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
679
                YYPREFIX, yystate, yyn, yyrule[yyn]);
680
#endif
681
2.71M
    yym = yylen[yyn];
682
2.71M
    if (yym)
683
2.09M
        yyval = yystack.l_mark[1-yym];
684
613k
    else
685
613k
        memset(&yyval, 0, sizeof yyval);
686
2.71M
    switch (yyn)
687
2.71M
    {
688
600k
case 11:
689
600k
  {
690
600k
    xml_parser_rule_print(
691
600k
     "xml_tag_open_start" );
692
693
600k
    if( yystack.l_mark[0].string_value.data == NULL )
694
0
    {
695
0
      libcerror_error_set(
696
0
       ( (xml_parser_state_t *) parser_state )->error,
697
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
698
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
699
0
       "%s: invalid tag name.",
700
0
       xml_parser_function );
701
702
0
      YYABORT;
703
0
    }
704
600k
    ( (xml_parser_state_t *) parser_state )->current_tag = NULL;
705
706
600k
    if( libfplist_xml_tag_initialize(
707
600k
         &( ( (xml_parser_state_t *) parser_state )->current_tag ),
708
600k
         (uint8_t *) yystack.l_mark[0].string_value.data,
709
600k
         yystack.l_mark[0].string_value.length,
710
600k
         ( (xml_parser_state_t *) parser_state )->error ) != 1 )
711
0
    {
712
0
      libcerror_error_set(
713
0
       ( (xml_parser_state_t *) parser_state )->error,
714
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
715
0
       LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
716
0
       "%s: unable to create XML tag.",
717
0
       xml_parser_function );
718
719
0
      YYABORT;
720
0
    }
721
600k
    if( ( (xml_parser_state_t *) parser_state )->root_tag == NULL )
722
2.17k
    {
723
2.17k
      ( (xml_parser_state_t *) parser_state )->root_tag = ( (xml_parser_state_t *) parser_state )->current_tag;
724
2.17k
    }
725
597k
    else
726
597k
    {
727
597k
      if( libfplist_xml_tag_append_element(
728
597k
           ( (xml_parser_state_t *) parser_state )->parent_tag,
729
597k
           ( (xml_parser_state_t *) parser_state )->current_tag,
730
597k
           ( (xml_parser_state_t *) parser_state )->error ) != 1 )
731
0
      {
732
0
        libcerror_error_set(
733
0
         ( (xml_parser_state_t *) parser_state )->error,
734
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
735
0
         LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
736
0
         "%s: unable to append attribute.",
737
0
         xml_parser_function );
738
739
0
        YYABORT;
740
0
      }
741
597k
    }
742
600k
    ( (xml_parser_state_t *) parser_state )->parent_tag = ( (xml_parser_state_t *) parser_state )->current_tag;
743
600k
  }
744
0
break;
745
159k
case 13:
746
159k
  {
747
159k
    xml_parser_rule_print(
748
159k
     "xml_tag_single" );
749
750
159k
    if( ( (xml_parser_state_t *) parser_state )->current_tag == NULL )
751
0
    {
752
0
      libcerror_error_set(
753
0
       ( (xml_parser_state_t *) parser_state )->error,
754
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
755
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
756
0
       "%s: invalid current tag.",
757
0
       xml_parser_function );
758
759
0
      YYABORT;
760
0
    }
761
159k
    ( (xml_parser_state_t *) parser_state )->parent_tag  = ( (xml_parser_state_t *) parser_state )->current_tag->parent_tag;
762
159k
    ( (xml_parser_state_t *) parser_state )->current_tag = ( (xml_parser_state_t *) parser_state )->parent_tag;
763
159k
  }
764
0
break;
765
164k
case 14:
766
164k
  {
767
164k
    xml_parser_rule_print(
768
164k
     "xml_tag_close" );
769
770
164k
    if( yystack.l_mark[0].string_value.data == NULL )
771
0
    {
772
0
      libcerror_error_set(
773
0
       ( (xml_parser_state_t *) parser_state )->error,
774
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
775
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
776
0
       "%s: invalid tag name.",
777
0
       xml_parser_function );
778
779
0
      YYABORT;
780
0
    }
781
164k
    if( ( (xml_parser_state_t *) parser_state )->current_tag == NULL )
782
0
    {
783
0
      libcerror_error_set(
784
0
       ( (xml_parser_state_t *) parser_state )->error,
785
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
786
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
787
0
       "%s: invalid current tag.",
788
0
       xml_parser_function );
789
790
0
      YYABORT;
791
0
    }
792
164k
    if( ( ( (xml_parser_state_t *) parser_state )->current_tag->name_size != ( yystack.l_mark[0].string_value.length + 1 ) )
793
164k
     || ( narrow_string_compare(
794
164k
           ( (xml_parser_state_t *) parser_state )->current_tag->name,
795
164k
           yystack.l_mark[0].string_value.data,
796
164k
           yystack.l_mark[0].string_value.length ) != 0 ) )
797
242
    {
798
242
      libcerror_error_set(
799
242
       ( (xml_parser_state_t *) parser_state )->error,
800
242
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
801
242
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
802
242
       "%s: mismatch in tag name (%s != %s).",
803
242
       xml_parser_function,
804
242
       ( (xml_parser_state_t *) parser_state )->current_tag->name,
805
242
       yystack.l_mark[0].string_value.data );
806
807
242
      YYABORT;
808
242
    }
809
164k
    ( (xml_parser_state_t *) parser_state )->parent_tag  = ( (xml_parser_state_t *) parser_state )->current_tag->parent_tag;
810
164k
    ( (xml_parser_state_t *) parser_state )->current_tag = ( (xml_parser_state_t *) parser_state )->parent_tag;
811
164k
  }
812
0
break;
813
153k
case 15:
814
153k
  {
815
153k
    xml_parser_rule_print(
816
153k
     "xml_tag_content" );
817
818
153k
    if( yystack.l_mark[0].string_value.data == NULL )
819
0
    {
820
0
      libcerror_error_set(
821
0
       ( (xml_parser_state_t *) parser_state )->error,
822
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
823
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
824
0
       "%s: invalid attribute value.",
825
0
       xml_parser_function );
826
827
0
      YYABORT;
828
0
    }
829
153k
    if( libfplist_xml_tag_set_value(
830
153k
         ( (xml_parser_state_t *) parser_state )->current_tag,
831
153k
         (uint8_t *) yystack.l_mark[0].string_value.data,
832
153k
         yystack.l_mark[0].string_value.length,
833
153k
         ( (xml_parser_state_t *) parser_state )->error ) != 1 )
834
0
    {
835
0
      libcerror_error_set(
836
0
       ( (xml_parser_state_t *) parser_state )->error,
837
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
838
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
839
0
       "%s: unable to set value.",
840
0
       xml_parser_function );
841
842
0
      YYABORT;
843
0
    }
844
153k
  }
845
153k
break;
846
153k
case 18:
847
3.37k
  {
848
3.37k
    xml_parser_rule_print(
849
3.37k
     "xml_attribute" );
850
851
3.37k
    if( yystack.l_mark[-2].string_value.data == NULL )
852
0
    {
853
0
      libcerror_error_set(
854
0
       ( (xml_parser_state_t *) parser_state )->error,
855
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
856
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
857
0
       "%s: invalid attribute name.",
858
0
       xml_parser_function );
859
860
0
      YYABORT;
861
0
    }
862
3.37k
    if( yystack.l_mark[0].string_value.data == NULL )
863
0
    {
864
0
      libcerror_error_set(
865
0
       ( (xml_parser_state_t *) parser_state )->error,
866
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
867
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
868
0
       "%s: invalid attribute value.",
869
0
       xml_parser_function );
870
871
0
      YYABORT;
872
0
    }
873
3.37k
    if( libfplist_xml_tag_append_attribute(
874
3.37k
         ( (xml_parser_state_t *) parser_state )->current_tag,
875
3.37k
         (uint8_t *) yystack.l_mark[-2].string_value.data,
876
3.37k
         yystack.l_mark[-2].string_value.length,
877
3.37k
         (uint8_t *) yystack.l_mark[0].string_value.data,
878
3.37k
         yystack.l_mark[0].string_value.length,
879
3.37k
         ( (xml_parser_state_t *) parser_state )->error ) != 1 )
880
15
    {
881
15
      libcerror_error_set(
882
15
       ( (xml_parser_state_t *) parser_state )->error,
883
15
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
884
15
       LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
885
15
       "%s: unable to append attribute.",
886
15
       xml_parser_function );
887
888
15
      YYABORT;
889
15
    }
890
3.37k
  }
891
3.35k
break;
892
2.71M
    }
893
2.71M
    yystack.s_mark -= yym;
894
2.71M
    yystate = *yystack.s_mark;
895
2.71M
    yystack.l_mark -= yym;
896
2.71M
    yym = yylhs[yyn];
897
2.71M
    if (yystate == 0 && yym == 0)
898
1.40k
    {
899
#if YYDEBUG
900
        if (yydebug)
901
            printf("%sdebug: after reduction, shifting from state 0 to\
902
 state %d\n", YYPREFIX, YYFINAL);
903
#endif
904
1.40k
        yystate = YYFINAL;
905
1.40k
        *++yystack.s_mark = YYFINAL;
906
1.40k
        *++yystack.l_mark = yyval;
907
1.40k
        if (yychar < 0)
908
1.40k
        {
909
1.40k
            if ((yychar = YYLEX) < 0) yychar = YYEOF;
910
#if YYDEBUG
911
            if (yydebug)
912
            {
913
                yys = yyname[YYTRANSLATE(yychar)];
914
                printf("%sdebug: state %d, reading %d (%s)\n",
915
                        YYPREFIX, YYFINAL, yychar, yys);
916
            }
917
#endif
918
1.40k
        }
919
1.40k
        if (yychar == YYEOF) goto yyaccept;
920
19
        goto yyloop;
921
1.40k
    }
922
2.71M
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
923
2.71M
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
924
1.02M
        yystate = yytable[yyn];
925
1.68M
    else
926
1.68M
        yystate = yydgoto[yym];
927
#if YYDEBUG
928
    if (yydebug)
929
        printf("%sdebug: after reduction, shifting from state %d \
930
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
931
#endif
932
2.71M
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
933
0
    {
934
0
        goto yyoverflow;
935
0
    }
936
2.71M
    *++yystack.s_mark = (YYINT) yystate;
937
2.71M
    *++yystack.l_mark = yyval;
938
2.71M
    goto yyloop;
939
940
2
yyoverflow:
941
2
    YYERROR_CALL("yacc stack overflow");
942
943
955
yyabort:
944
955
    yyfreestack(&yystack);
945
955
    return (1);
946
947
1.38k
yyaccept:
948
1.38k
    yyfreestack(&yystack);
949
1.38k
    return (0);
950
2
}