Coverage Report

Created: 2026-04-10 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libmodi/libfplist/libfplist_xml_parser.c
Line
Count
Source
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
2.41M
#define YYEMPTY        (-1)
11
#define yyclearin      (yychar = YYEMPTY)
12
#define yyerrok        (yyerrflag = 0)
13
#define YYRECOVERING() (yyerrflag != 0)
14
36
#define YYENOMEM       (-2)
15
1.85k
#define YYEOF          0
16
17
#ifndef yyparse
18
#define yyparse    libfplist_xml_scanner_parse
19
#endif /* yyparse */
20
21
#ifndef yylex
22
2.41M
#define yylex      libfplist_xml_scanner_lex
23
#endif /* yylex */
24
25
#ifndef yyerror
26
1.73k
#define yyerror    libfplist_xml_scanner_error
27
#endif /* yyerror */
28
29
#ifndef yychar
30
17.5M
#define yychar     libfplist_xml_scanner_char
31
#endif /* yychar */
32
33
#ifndef yyval
34
9.70M
#define yyval      libfplist_xml_scanner_val
35
#endif /* yyval */
36
37
#ifndef yylval
38
2.41M
#define yylval     libfplist_xml_scanner_lval
39
#endif /* yylval */
40
41
#ifndef yydebug
42
#define yydebug    libfplist_xml_scanner_debug
43
#endif /* yydebug */
44
45
#ifndef yynerrs
46
5.87k
#define yynerrs    libfplist_xml_scanner_nerrs
47
#endif /* yynerrs */
48
49
#ifndef yyerrflag
50
2.42M
#define yyerrflag  libfplist_xml_scanner_errflag
51
#endif /* yyerrflag */
52
53
#ifndef yylhs
54
4.30M
#define yylhs      libfplist_xml_scanner_lhs
55
#endif /* yylhs */
56
57
#ifndef yylen
58
4.30M
#define yylen      libfplist_xml_scanner_len
59
#endif /* yylen */
60
61
#ifndef yydefred
62
6.72M
#define yydefred   libfplist_xml_scanner_defred
63
#endif /* yydefred */
64
65
#ifndef yydgoto
66
2.78M
#define yydgoto    libfplist_xml_scanner_dgoto
67
#endif /* yydgoto */
68
69
#ifndef yysindex
70
4.20M
#define yysindex   libfplist_xml_scanner_sindex
71
#endif /* yysindex */
72
73
#ifndef yyrindex
74
1.09M
#define yyrindex   libfplist_xml_scanner_rindex
75
#endif /* yyrindex */
76
77
#ifndef yygindex
78
4.30M
#define yygindex   libfplist_xml_scanner_gindex
79
#endif /* yygindex */
80
81
#ifndef yytable
82
7.43M
#define yytable    libfplist_xml_scanner_table
83
#endif /* yytable */
84
85
#ifndef yycheck
86
6.12M
#define yycheck    libfplist_xml_scanner_check
87
#endif /* yycheck */
88
89
#ifndef yyname
90
#define yyname     libfplist_xml_scanner_name
91
#endif /* yyname */
92
93
#ifndef yyrule
94
#define yyrule     libfplist_xml_scanner_rule
95
#endif /* yyrule */
96
#define YYPREFIX "libfplist_xml_scanner_"
97
98
#define YYPURE 0
99
100
/*
101
 * XML parser functions
102
 *
103
 * Copyright (C) 2016-2024, 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  libfplist_xml_scanner_alloc
137
#define YYREALLOC libfplist_xml_scanner_realloc
138
#define YYFREE    libfplist_xml_scanner_free
139
140
2.41M
#define YYLEX_PARAM NULL
141
#define YYPARSE_PARAM parser_state
142
143
#if defined( HAVE_DEBUG_OUTPUT )
144
#define libfplist_xml_parser_rule_print( string ) \
145
  if( libcnotify_verbose != 0 ) libcnotify_printf( "libfplist_xml_parser: rule: %s\n", string )
146
#else
147
#define libfplist_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 libfplist_xml_parser_state libfplist_xml_parser_state_t;
179
180
struct libfplist_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 libfplist_xml_scanner_suppress_error;
208
209
extern \
210
int libfplist_xml_scanner_lex_destroy(
211
     void );
212
213
extern \
214
void *libfplist_xml_scanner_alloc(
215
       yy_size_t size );
216
217
extern \
218
void *libfplist_xml_scanner_realloc(
219
       void *buffer,
220
       yy_size_t size );
221
222
extern \
223
void *libfplist_xml_scanner_free(
224
       void *buffer );
225
226
extern \
227
int libfplist_xml_scanner_lex(
228
     void *user_data );
229
230
extern \
231
void libfplist_xml_scanner_error(
232
      void *parser_state,
233
      const char *error_string );
234
235
extern \
236
YY_BUFFER_STATE libfplist_xml_scanner__scan_buffer(
237
                 char *buffer,
238
                 yy_size_t buffer_size );
239
240
extern \
241
void libfplist_xml_scanner__delete_buffer(
242
      YY_BUFFER_STATE buffer_state );
243
244
extern \
245
size_t libfplist_xml_scanner_buffer_offset;
246
247
static char *libfplist_xml_parser_function = "libfplist_xml_parser";
248
249
int libfplist_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
2.41M
# 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
1.73k
#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
709k
#define YYERRCODE 256
300
typedef short YYINT;
301
static const YYINT libfplist_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 libfplist_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 libfplist_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 libfplist_xml_scanner_dgoto[] = {      2,
315
    3,    5,    9,   10,   21,   11,   19,   12,   13,   15,
316
   16,
317
};
318
static const YYINT libfplist_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 libfplist_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 libfplist_xml_scanner_gindex[] = {     0,
329
    0,    0,   18,   -6,   -4,    0,    0,    0,   21,  -12,
330
    0,
331
};
332
17.4M
#define YYTABLESIZE 26
333
static const YYINT libfplist_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 libfplist_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
3.71k
#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 libfplist_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 libfplist_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 libfplist_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
4.14k
{
429
4.14k
  libfplist_xml_parser_state_t parser_state;
430
  
431
4.14k
  YY_BUFFER_STATE buffer_state = NULL;
432
4.14k
  static char *function        = "libfplist_xml_parser_parse_buffer";
433
4.14k
  int result                   = -1;
434
435
4.14k
  if( buffer == NULL )
436
0
  {
437
0
    libcerror_error_set(
438
0
     error,
439
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
440
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
441
0
     "%s: invalid buffer.",
442
0
     function );
443
444
0
    return( -1 );
445
0
  }
446
4.14k
  buffer_state = libfplist_xml_scanner__scan_buffer(
447
4.14k
                  (char *) buffer,
448
4.14k
                  buffer_size );
449
450
4.14k
  libfplist_xml_scanner_buffer_offset = 0;
451
452
4.14k
  if( buffer_state != NULL )
453
4.14k
  {
454
4.14k
    parser_state.property_list = property_list;
455
4.14k
    parser_state.error         = error;
456
4.14k
    parser_state.root_tag      = NULL;
457
4.14k
    parser_state.current_tag   = NULL;
458
4.14k
    parser_state.parent_tag    = NULL;
459
460
4.14k
    if( libfplist_xml_scanner_parse(
461
4.14k
         &parser_state ) == 0 )
462
1.80k
    {
463
1.80k
      if( libfplist_property_list_set_root_tag(
464
1.80k
           property_list,
465
1.80k
           parser_state.root_tag,
466
1.80k
           error ) != 1 )
467
0
      {
468
0
        libcerror_error_set(
469
0
         error,
470
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
471
0
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
472
0
         "%s: unable to set root tag.",
473
0
         function );
474
475
0
        result = -1;
476
0
      }
477
1.80k
      else
478
1.80k
      {
479
1.80k
        parser_state.root_tag = NULL;
480
481
1.80k
        result = 1;
482
1.80k
      }
483
1.80k
    }
484
4.14k
    libfplist_xml_scanner__delete_buffer(
485
4.14k
     buffer_state );
486
4.14k
  }
487
4.14k
  libfplist_xml_scanner_lex_destroy();
488
489
4.14k
  if( parser_state.root_tag != NULL )
490
1.87k
  {
491
1.87k
    libfplist_xml_tag_free(
492
1.87k
     &( parser_state.root_tag ),
493
1.87k
     NULL );
494
1.87k
  }
495
4.14k
  return( result );
496
4.14k
}
497
498
499
#if YYDEBUG
500
#include <stdio.h>    /* needed for printf */
501
#endif
502
503
#include <stdlib.h> /* needed for malloc, etc */
504
#include <string.h> /* needed for memset */
505
506
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
507
static int yygrowstack(YYSTACKDATA *data)
508
32
{
509
32
    int i;
510
32
    unsigned newsize;
511
32
    YYINT *newss;
512
32
    YYSTYPE *newvs;
513
514
32
    if ((newsize = data->stacksize) == 0)
515
4
        newsize = YYINITSTACKSIZE;
516
28
    else if (newsize >= YYMAXDEPTH)
517
4
        return YYENOMEM;
518
24
    else if ((newsize *= 2) > YYMAXDEPTH)
519
4
        newsize = YYMAXDEPTH;
520
521
28
    i = (int) (data->s_mark - data->s_base);
522
28
    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
523
28
    if (newss == 0)
524
0
        return YYENOMEM;
525
526
28
    data->s_base = newss;
527
28
    data->s_mark = newss + i;
528
529
28
    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
530
28
    if (newvs == 0)
531
0
        return YYENOMEM;
532
533
28
    data->l_base = newvs;
534
28
    data->l_mark = newvs + i;
535
536
28
    data->stacksize = newsize;
537
28
    data->s_last = data->s_base + newsize - 1;
538
28
    return 0;
539
28
}
540
541
#if YYPURE || defined(YY_NO_LEAKS)
542
static void yyfreestack(YYSTACKDATA *data)
543
{
544
    free(data->s_base);
545
    free(data->l_base);
546
    memset(data, 0, sizeof(*data));
547
}
548
#else
549
#define yyfreestack(data) /* nothing */
550
#endif
551
552
612
#define YYABORT  goto yyabort
553
#define YYREJECT goto yyabort
554
#define YYACCEPT goto yyaccept
555
#define YYERROR  goto yyerrlab
556
557
int
558
YYPARSE_DECL()
559
4.14k
{
560
4.14k
    int yym, yyn, yystate;
561
#if YYDEBUG
562
    const char *yys;
563
564
    if ((yys = getenv("YYDEBUG")) != 0)
565
    {
566
        yyn = *yys;
567
        if (yyn >= '0' && yyn <= '9')
568
            yydebug = yyn - '0';
569
    }
570
#endif
571
572
4.14k
    yynerrs = 0;
573
4.14k
    yyerrflag = 0;
574
4.14k
    yychar = YYEMPTY;
575
4.14k
    yystate = 0;
576
577
#if YYPURE
578
    memset(&yystack, 0, sizeof(yystack));
579
#endif
580
581
4.14k
    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
582
4.14k
    yystack.s_mark = yystack.s_base;
583
4.14k
    yystack.l_mark = yystack.l_base;
584
4.14k
    yystate = 0;
585
4.14k
    *yystack.s_mark = 0;
586
587
6.72M
yyloop:
588
6.72M
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
589
3.50M
    if (yychar < 0)
590
2.41M
    {
591
2.41M
        if ((yychar = YYLEX) < 0) yychar = YYEOF;
592
#if YYDEBUG
593
        if (yydebug)
594
        {
595
            yys = yyname[YYTRANSLATE(yychar)];
596
            printf("%sdebug: state %d, reading %d (%s)\n",
597
                    YYPREFIX, yystate, yychar, yys);
598
        }
599
#endif
600
2.41M
    }
601
3.50M
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
602
3.50M
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
603
2.41M
    {
604
#if YYDEBUG
605
        if (yydebug)
606
            printf("%sdebug: state %d, shifting to state %d\n",
607
                    YYPREFIX, yystate, yytable[yyn]);
608
#endif
609
2.41M
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
610
4
        {
611
4
            goto yyoverflow;
612
4
        }
613
2.41M
        yystate = yytable[yyn];
614
2.41M
        *++yystack.s_mark = yytable[yyn];
615
2.41M
        *++yystack.l_mark = yylval;
616
2.41M
        yychar = YYEMPTY;
617
2.41M
        if (yyerrflag > 0)  --yyerrflag;
618
2.41M
        goto yyloop;
619
2.41M
    }
620
1.09M
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
621
1.09M
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
622
1.09M
    {
623
1.09M
        yyn = yytable[yyn];
624
1.09M
        goto yyreduce;
625
1.09M
    }
626
1.72k
    if (yyerrflag) goto yyinrecovery;
627
628
1.72k
    YYERROR_CALL("syntax error");
629
630
1.72k
    goto yyerrlab;
631
632
1.72k
yyerrlab:
633
1.72k
    ++yynerrs;
634
635
1.72k
yyinrecovery:
636
1.72k
    if (yyerrflag < 3)
637
1.72k
    {
638
1.72k
        yyerrflag = 3;
639
1.72k
        for (;;)
640
705k
        {
641
705k
            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
642
4.33k
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
643
0
            {
644
#if YYDEBUG
645
                if (yydebug)
646
                    printf("%sdebug: state %d, error recovery shifting\
647
 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
648
#endif
649
0
                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
650
0
                {
651
0
                    goto yyoverflow;
652
0
                }
653
0
                yystate = yytable[yyn];
654
0
                *++yystack.s_mark = yytable[yyn];
655
0
                *++yystack.l_mark = yylval;
656
0
                goto yyloop;
657
0
            }
658
705k
            else
659
705k
            {
660
#if YYDEBUG
661
                if (yydebug)
662
                    printf("%sdebug: error recovery discarding state %d\n",
663
                            YYPREFIX, *yystack.s_mark);
664
#endif
665
705k
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
666
703k
                --yystack.s_mark;
667
703k
                --yystack.l_mark;
668
703k
            }
669
705k
        }
670
1.72k
    }
671
0
    else
672
0
    {
673
0
        if (yychar == YYEOF) goto yyabort;
674
#if YYDEBUG
675
        if (yydebug)
676
        {
677
            yys = yyname[YYTRANSLATE(yychar)];
678
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
679
                    YYPREFIX, yystate, yychar, yys);
680
        }
681
#endif
682
0
        yychar = YYEMPTY;
683
0
        goto yyloop;
684
0
    }
685
686
4.30M
yyreduce:
687
#if YYDEBUG
688
    if (yydebug)
689
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
690
                YYPREFIX, yystate, yyn, yyrule[yyn]);
691
#endif
692
4.30M
    yym = yylen[yyn];
693
4.30M
    if (yym)
694
3.21M
        yyval = yystack.l_mark[1-yym];
695
1.09M
    else
696
1.09M
        memset(&yyval, 0, sizeof yyval);
697
4.30M
    switch (yyn)
698
4.30M
    {
699
1.07M
case 11:
700
1.07M
  {
701
1.07M
    libfplist_xml_parser_rule_print(
702
1.07M
     "xml_tag_open_start" );
703
704
1.07M
    if( yystack.l_mark[0].string_value.data == NULL )
705
0
    {
706
0
      libcerror_error_set(
707
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
708
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
709
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
710
0
       "%s: invalid tag name.",
711
0
       libfplist_xml_parser_function );
712
713
0
      YYABORT;
714
0
    }
715
1.07M
    ( (libfplist_xml_parser_state_t *) parser_state )->current_tag = NULL;
716
717
1.07M
    if( libfplist_xml_tag_initialize(
718
1.07M
         &( ( (libfplist_xml_parser_state_t *) parser_state )->current_tag ),
719
1.07M
         (uint8_t *) yystack.l_mark[0].string_value.data,
720
1.07M
         yystack.l_mark[0].string_value.length,
721
1.07M
         ( (libfplist_xml_parser_state_t *) parser_state )->error ) != 1 )
722
0
    {
723
0
      libcerror_error_set(
724
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
725
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
726
0
       LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
727
0
       "%s: unable to create XML tag.",
728
0
       libfplist_xml_parser_function );
729
730
0
      YYABORT;
731
0
    }
732
1.07M
    if( ( (libfplist_xml_parser_state_t *) parser_state )->root_tag == NULL )
733
3.67k
    {
734
3.67k
      ( (libfplist_xml_parser_state_t *) parser_state )->root_tag = ( (libfplist_xml_parser_state_t *) parser_state )->current_tag;
735
3.67k
    }
736
1.07M
    else
737
1.07M
    {
738
1.07M
      if( libfplist_xml_tag_append_element(
739
1.07M
           ( (libfplist_xml_parser_state_t *) parser_state )->parent_tag,
740
1.07M
           ( (libfplist_xml_parser_state_t *) parser_state )->current_tag,
741
1.07M
           ( (libfplist_xml_parser_state_t *) parser_state )->error ) != 1 )
742
0
      {
743
0
        libcerror_error_set(
744
0
         ( (libfplist_xml_parser_state_t *) parser_state )->error,
745
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
746
0
         LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
747
0
         "%s: unable to append attribute.",
748
0
         libfplist_xml_parser_function );
749
750
0
        YYABORT;
751
0
      }
752
1.07M
    }
753
1.07M
    ( (libfplist_xml_parser_state_t *) parser_state )->parent_tag = ( (libfplist_xml_parser_state_t *) parser_state )->current_tag;
754
1.07M
  }
755
0
break;
756
379k
case 13:
757
379k
  {
758
379k
    libfplist_xml_parser_rule_print(
759
379k
     "xml_tag_single" );
760
761
379k
    if( ( (libfplist_xml_parser_state_t *) parser_state )->current_tag == NULL )
762
0
    {
763
0
      libcerror_error_set(
764
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
765
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
766
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
767
0
       "%s: invalid current tag.",
768
0
       libfplist_xml_parser_function );
769
770
0
      YYABORT;
771
0
    }
772
379k
    ( (libfplist_xml_parser_state_t *) parser_state )->parent_tag  = ( (libfplist_xml_parser_state_t *) parser_state )->current_tag->parent_tag;
773
379k
    ( (libfplist_xml_parser_state_t *) parser_state )->current_tag = ( (libfplist_xml_parser_state_t *) parser_state )->parent_tag;
774
379k
  }
775
0
break;
776
127k
case 14:
777
127k
  {
778
127k
    libfplist_xml_parser_rule_print(
779
127k
     "xml_tag_close" );
780
781
127k
    if( yystack.l_mark[0].string_value.data == NULL )
782
0
    {
783
0
      libcerror_error_set(
784
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
785
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
786
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
787
0
       "%s: invalid tag name.",
788
0
       libfplist_xml_parser_function );
789
790
0
      YYABORT;
791
0
    }
792
127k
    if( ( (libfplist_xml_parser_state_t *) parser_state )->current_tag == NULL )
793
0
    {
794
0
      libcerror_error_set(
795
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
796
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
797
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
798
0
       "%s: invalid current tag.",
799
0
       libfplist_xml_parser_function );
800
801
0
      YYABORT;
802
0
    }
803
127k
    if( ( ( (libfplist_xml_parser_state_t *) parser_state )->current_tag->name_size != ( yystack.l_mark[0].string_value.length + 1 ) )
804
127k
     || ( narrow_string_compare(
805
127k
           ( (libfplist_xml_parser_state_t *) parser_state )->current_tag->name,
806
127k
           yystack.l_mark[0].string_value.data,
807
127k
           yystack.l_mark[0].string_value.length ) != 0 ) )
808
568
    {
809
568
      libcerror_error_set(
810
568
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
811
568
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
812
568
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
813
568
       "%s: mismatch in tag name (%s != %s).",
814
568
       libfplist_xml_parser_function,
815
568
       ( (libfplist_xml_parser_state_t *) parser_state )->current_tag->name,
816
568
       yystack.l_mark[0].string_value.data );
817
818
568
      YYABORT;
819
568
    }
820
127k
    ( (libfplist_xml_parser_state_t *) parser_state )->parent_tag  = ( (libfplist_xml_parser_state_t *) parser_state )->current_tag->parent_tag;
821
127k
    ( (libfplist_xml_parser_state_t *) parser_state )->current_tag = ( (libfplist_xml_parser_state_t *) parser_state )->parent_tag;
822
127k
  }
823
0
break;
824
117k
case 15:
825
117k
  {
826
117k
    libfplist_xml_parser_rule_print(
827
117k
     "xml_tag_content" );
828
829
117k
    if( yystack.l_mark[0].string_value.data == NULL )
830
0
    {
831
0
      libcerror_error_set(
832
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
833
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
834
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
835
0
       "%s: invalid attribute value.",
836
0
       libfplist_xml_parser_function );
837
838
0
      YYABORT;
839
0
    }
840
117k
    if( libfplist_xml_tag_set_value(
841
117k
         ( (libfplist_xml_parser_state_t *) parser_state )->current_tag,
842
117k
         (uint8_t *) yystack.l_mark[0].string_value.data,
843
117k
         yystack.l_mark[0].string_value.length,
844
117k
         ( (libfplist_xml_parser_state_t *) parser_state )->error ) != 1 )
845
0
    {
846
0
      libcerror_error_set(
847
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
848
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
849
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
850
0
       "%s: unable to set value.",
851
0
       libfplist_xml_parser_function );
852
853
0
      YYABORT;
854
0
    }
855
117k
  }
856
117k
break;
857
117k
case 18:
858
5.31k
  {
859
5.31k
    libfplist_xml_parser_rule_print(
860
5.31k
     "xml_attribute" );
861
862
5.31k
    if( yystack.l_mark[-2].string_value.data == NULL )
863
0
    {
864
0
      libcerror_error_set(
865
0
       ( (libfplist_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 name.",
869
0
       libfplist_xml_parser_function );
870
871
0
      YYABORT;
872
0
    }
873
5.31k
    if( yystack.l_mark[0].string_value.data == NULL )
874
0
    {
875
0
      libcerror_error_set(
876
0
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
877
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
878
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
879
0
       "%s: invalid attribute value.",
880
0
       libfplist_xml_parser_function );
881
882
0
      YYABORT;
883
0
    }
884
5.31k
    if( libfplist_xml_tag_append_attribute(
885
5.31k
         ( (libfplist_xml_parser_state_t *) parser_state )->current_tag,
886
5.31k
         (uint8_t *) yystack.l_mark[-2].string_value.data,
887
5.31k
         yystack.l_mark[-2].string_value.length,
888
5.31k
         (uint8_t *) yystack.l_mark[0].string_value.data,
889
5.31k
         yystack.l_mark[0].string_value.length,
890
5.31k
         ( (libfplist_xml_parser_state_t *) parser_state )->error ) != 1 )
891
44
    {
892
44
      libcerror_error_set(
893
44
       ( (libfplist_xml_parser_state_t *) parser_state )->error,
894
44
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
895
44
       LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
896
44
       "%s: unable to append attribute.",
897
44
       libfplist_xml_parser_function );
898
899
44
      YYABORT;
900
44
    }
901
5.31k
  }
902
5.27k
break;
903
4.30M
    }
904
4.30M
    yystack.s_mark -= yym;
905
4.30M
    yystate = *yystack.s_mark;
906
4.30M
    yystack.l_mark -= yym;
907
4.30M
    yym = yylhs[yyn];
908
4.30M
    if (yystate == 0 && yym == 0)
909
1.85k
    {
910
#if YYDEBUG
911
        if (yydebug)
912
            printf("%sdebug: after reduction, shifting from state 0 to\
913
 state %d\n", YYPREFIX, YYFINAL);
914
#endif
915
1.85k
        yystate = YYFINAL;
916
1.85k
        *++yystack.s_mark = YYFINAL;
917
1.85k
        *++yystack.l_mark = yyval;
918
1.85k
        if (yychar < 0)
919
1.85k
        {
920
1.85k
            if ((yychar = YYLEX) < 0) yychar = YYEOF;
921
#if YYDEBUG
922
            if (yydebug)
923
            {
924
                yys = yyname[YYTRANSLATE(yychar)];
925
                printf("%sdebug: state %d, reading %d (%s)\n",
926
                        YYPREFIX, YYFINAL, yychar, yys);
927
            }
928
#endif
929
1.85k
        }
930
1.85k
        if (yychar == YYEOF) goto yyaccept;
931
52
        goto yyloop;
932
1.85k
    }
933
4.30M
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
934
3.28M
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
935
1.52M
        yystate = yytable[yyn];
936
2.78M
    else
937
2.78M
        yystate = yydgoto[yym];
938
#if YYDEBUG
939
    if (yydebug)
940
        printf("%sdebug: after reduction, shifting from state %d \
941
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
942
#endif
943
4.30M
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
944
0
    {
945
0
        goto yyoverflow;
946
0
    }
947
4.30M
    *++yystack.s_mark = (YYINT) yystate;
948
4.30M
    *++yystack.l_mark = yyval;
949
4.30M
    goto yyloop;
950
951
4
yyoverflow:
952
4
    YYERROR_CALL("yacc stack overflow");
953
954
2.34k
yyabort:
955
2.34k
    yyfreestack(&yystack);
956
2.34k
    return (1);
957
958
1.80k
yyaccept:
959
1.80k
    yyfreestack(&yystack);
960
1.80k
    return (0);
961
4
}