Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libevtx/ossfuzz/record_fuzzer.cc
Line
Count
Source
1
/*
2
 * OSS-Fuzz target for libevtx record type
3
 *
4
 * Copyright (C) 2011-2026, Joachim Metz <joachim.metz@gmail.com>
5
 *
6
 * Refer to AUTHORS for acknowledgements.
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
#include <stddef.h>
23
#include <stdint.h>
24
25
#include <stdlib.h>
26
27
/* Note that some of the OSS-Fuzz engines use C++
28
 */
29
extern "C" {
30
31
#include "ossfuzz_libbfio.h"
32
#include "ossfuzz_libevtx.h"
33
34
#if !defined( LIBEVTX_HAVE_BFIO )
35
36
/* Opens a file using a Basic File IO (bfio) handle
37
 * Returns 1 if successful or -1 on error
38
 */
39
LIBEVTX_EXTERN \
40
int libevtx_file_open_file_io_handle(
41
      libevtx_file_t *file,
42
      libbfio_handle_t *file_io_handle,
43
      int access_flags,
44
      libevtx_error_t **error );
45
46
#endif /* !defined( LIBEVTX_HAVE_BFIO ) */
47
48
/* Limits on the traversal and buffer sizes to bound the time a single input takes
49
 */
50
5.52k
#define FUZZER_RECORD_LIMIT        4
51
5.10k
#define FUZZER_STRING_LIMIT        8
52
24.5k
#define FUZZER_STRING_SIZE_LIMIT   ( (size_t) 0x00100000 )
53
54
/* The ASCII codepages supported by libevtx_file_set_ascii_codepage
55
 */
56
static const int file_codepages[] = {
57
  LIBEVTX_CODEPAGE_ASCII,
58
  LIBEVTX_CODEPAGE_WINDOWS_874,
59
  LIBEVTX_CODEPAGE_WINDOWS_932,
60
  LIBEVTX_CODEPAGE_WINDOWS_936,
61
  LIBEVTX_CODEPAGE_WINDOWS_949,
62
  LIBEVTX_CODEPAGE_WINDOWS_950,
63
  LIBEVTX_CODEPAGE_WINDOWS_1250,
64
  LIBEVTX_CODEPAGE_WINDOWS_1251,
65
  LIBEVTX_CODEPAGE_WINDOWS_1252,
66
  LIBEVTX_CODEPAGE_WINDOWS_1253,
67
  LIBEVTX_CODEPAGE_WINDOWS_1254,
68
  LIBEVTX_CODEPAGE_WINDOWS_1255,
69
  LIBEVTX_CODEPAGE_WINDOWS_1256,
70
  LIBEVTX_CODEPAGE_WINDOWS_1257,
71
  LIBEVTX_CODEPAGE_WINDOWS_1258
72
};
73
74
static const size_t file_number_of_codepages =
75
    sizeof( file_codepages ) / sizeof( file_codepages[ 0 ] );
76
77
/* Decodes the record using the typed accessors
78
 * Returns 1 if successful or -1 on error
79
 */
80
int record_decode_fuzzer(
81
      libevtx_record_t *record )
82
1.89k
{
83
1.89k
  uint8_t *utf8_string                   = NULL;
84
1.89k
  uint16_t *utf16_string                 = NULL;
85
1.89k
  uint8_t *data_buffer                   = NULL;
86
1.89k
  off64_t offset                         = 0;
87
1.89k
  size_t utf8_string_size                = 0;
88
1.89k
  size_t utf16_string_size               = 0;
89
1.89k
  size_t data_size                       = 0;
90
1.89k
  uint64_t creation_time                 = 0;
91
1.89k
  uint64_t identifier                    = 0;
92
1.89k
  uint64_t written_time                  = 0;
93
1.89k
  uint32_t event_identifier               = 0;
94
1.89k
  uint32_t event_identifier_qualifiers    = 0;
95
1.89k
  uint8_t event_level                    = 0;
96
1.89k
  uint8_t event_version                  = 0;
97
1.89k
  uint8_t value_byte                     = 0;
98
1.89k
  int number_of_strings                  = 0;
99
1.89k
  int string_index                       = 0;
100
1.89k
  int result                             = 0;
101
102
1.89k
  if( record == NULL )
103
0
  {
104
0
    return( -1 );
105
0
  }
106
1.89k
  libevtx_record_get_offset(
107
1.89k
   record,
108
1.89k
   &offset,
109
1.89k
   NULL );
110
111
1.89k
  libevtx_record_get_identifier(
112
1.89k
   record,
113
1.89k
   &identifier,
114
1.89k
   NULL );
115
116
  /* Note that not all record fields are present in a record
117
   */
118
1.89k
  libevtx_record_get_creation_time(
119
1.89k
   record,
120
1.89k
   &creation_time,
121
1.89k
   NULL );
122
123
1.89k
  libevtx_record_get_written_time(
124
1.89k
   record,
125
1.89k
   &written_time,
126
1.89k
   NULL );
127
128
1.89k
  libevtx_record_get_event_identifier(
129
1.89k
   record,
130
1.89k
   &event_identifier,
131
1.89k
   NULL );
132
133
  /* Note that not all record fields are present in a record
134
   */
135
1.89k
  libevtx_record_get_event_identifier_qualifiers(
136
1.89k
   record,
137
1.89k
   &event_identifier_qualifiers,
138
1.89k
   NULL );
139
140
1.89k
  libevtx_record_get_event_version(
141
1.89k
   record,
142
1.89k
   &event_version,
143
1.89k
   NULL );
144
145
1.89k
  libevtx_record_get_event_level(
146
1.89k
   record,
147
1.89k
   &event_level,
148
1.89k
   NULL );
149
150
1.89k
  result = libevtx_record_get_utf8_provider_identifier_size(
151
1.89k
            record,
152
1.89k
            &utf8_string_size,
153
1.89k
            NULL );
154
155
1.89k
  if( ( result == 1 )
156
1.26k
   && ( utf8_string_size > 0 )
157
1.24k
   && ( utf8_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
158
1.24k
  {
159
1.24k
    utf8_string = (uint8_t *) malloc( utf8_string_size );
160
161
1.24k
    if( utf8_string != NULL )
162
1.24k
    {
163
1.24k
      if( libevtx_record_get_utf8_provider_identifier(
164
1.24k
           record,
165
1.24k
           utf8_string,
166
1.24k
           utf8_string_size,
167
1.24k
           NULL ) == 1 )
168
1.24k
      {
169
1.24k
        value_byte ^= utf8_string[ 0 ];
170
1.24k
      }
171
1.24k
      free( utf8_string );
172
1.24k
    }
173
1.24k
  }
174
  /* The size is the number of UTF-16 characters,
175
   * including the end of string character
176
   */
177
1.89k
  result = libevtx_record_get_utf16_provider_identifier_size(
178
1.89k
            record,
179
1.89k
            &utf16_string_size,
180
1.89k
            NULL );
181
182
1.89k
  if( ( result == 1 )
183
1.26k
   && ( utf16_string_size > 0 )
184
1.24k
   && ( utf16_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
185
1.24k
  {
186
1.24k
    utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
187
188
1.24k
    if( utf16_string != NULL )
189
1.24k
    {
190
1.24k
      if( libevtx_record_get_utf16_provider_identifier(
191
1.24k
           record,
192
1.24k
           utf16_string,
193
1.24k
           utf16_string_size,
194
1.24k
           NULL ) == 1 )
195
1.24k
      {
196
1.24k
        value_byte ^= (uint8_t) utf16_string[ 0 ];
197
1.24k
      }
198
1.24k
      free( utf16_string );
199
1.24k
    }
200
1.24k
  }
201
1.89k
  result = libevtx_record_get_utf8_source_name_size(
202
1.89k
            record,
203
1.89k
            &utf8_string_size,
204
1.89k
            NULL );
205
206
1.89k
  if( ( result == 1 )
207
1.43k
   && ( utf8_string_size > 0 )
208
1.42k
   && ( utf8_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
209
1.42k
  {
210
1.42k
    utf8_string = (uint8_t *) malloc( utf8_string_size );
211
212
1.42k
    if( utf8_string != NULL )
213
1.42k
    {
214
1.42k
      if( libevtx_record_get_utf8_source_name(
215
1.42k
           record,
216
1.42k
           utf8_string,
217
1.42k
           utf8_string_size,
218
1.42k
           NULL ) == 1 )
219
1.42k
      {
220
1.42k
        value_byte ^= utf8_string[ 0 ];
221
1.42k
      }
222
1.42k
      free( utf8_string );
223
1.42k
    }
224
1.42k
  }
225
  /* The size is the number of UTF-16 characters,
226
   * including the end of string character
227
   */
228
1.89k
  result = libevtx_record_get_utf16_source_name_size(
229
1.89k
            record,
230
1.89k
            &utf16_string_size,
231
1.89k
            NULL );
232
233
1.89k
  if( ( result == 1 )
234
1.43k
   && ( utf16_string_size > 0 )
235
1.42k
   && ( utf16_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
236
1.42k
  {
237
1.42k
    utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
238
239
1.42k
    if( utf16_string != NULL )
240
1.42k
    {
241
1.42k
      if( libevtx_record_get_utf16_source_name(
242
1.42k
           record,
243
1.42k
           utf16_string,
244
1.42k
           utf16_string_size,
245
1.42k
           NULL ) == 1 )
246
1.42k
      {
247
1.42k
        value_byte ^= (uint8_t) utf16_string[ 0 ];
248
1.42k
      }
249
1.42k
      free( utf16_string );
250
1.42k
    }
251
1.42k
  }
252
1.89k
  result = libevtx_record_get_utf8_channel_name_size(
253
1.89k
            record,
254
1.89k
            &utf8_string_size,
255
1.89k
            NULL );
256
257
1.89k
  if( ( result == 1 )
258
1.49k
   && ( utf8_string_size > 0 )
259
1.48k
   && ( utf8_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
260
1.48k
  {
261
1.48k
    utf8_string = (uint8_t *) malloc( utf8_string_size );
262
263
1.48k
    if( utf8_string != NULL )
264
1.48k
    {
265
1.48k
      if( libevtx_record_get_utf8_channel_name(
266
1.48k
           record,
267
1.48k
           utf8_string,
268
1.48k
           utf8_string_size,
269
1.48k
           NULL ) == 1 )
270
1.48k
      {
271
1.48k
        value_byte ^= utf8_string[ 0 ];
272
1.48k
      }
273
1.48k
      free( utf8_string );
274
1.48k
    }
275
1.48k
  }
276
  /* The size is the number of UTF-16 characters,
277
   * including the end of string character
278
   */
279
1.89k
  result = libevtx_record_get_utf16_channel_name_size(
280
1.89k
            record,
281
1.89k
            &utf16_string_size,
282
1.89k
            NULL );
283
284
1.89k
  if( ( result == 1 )
285
1.49k
   && ( utf16_string_size > 0 )
286
1.48k
   && ( utf16_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
287
1.48k
  {
288
1.48k
    utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
289
290
1.48k
    if( utf16_string != NULL )
291
1.48k
    {
292
1.48k
      if( libevtx_record_get_utf16_channel_name(
293
1.48k
           record,
294
1.48k
           utf16_string,
295
1.48k
           utf16_string_size,
296
1.48k
           NULL ) == 1 )
297
1.48k
      {
298
1.48k
        value_byte ^= (uint8_t) utf16_string[ 0 ];
299
1.48k
      }
300
1.48k
      free( utf16_string );
301
1.48k
    }
302
1.48k
  }
303
1.89k
  result = libevtx_record_get_utf8_computer_name_size(
304
1.89k
            record,
305
1.89k
            &utf8_string_size,
306
1.89k
            NULL );
307
308
1.89k
  if( ( result == 1 )
309
1.37k
   && ( utf8_string_size > 0 )
310
1.35k
   && ( utf8_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
311
1.35k
  {
312
1.35k
    utf8_string = (uint8_t *) malloc( utf8_string_size );
313
314
1.35k
    if( utf8_string != NULL )
315
1.35k
    {
316
1.35k
      if( libevtx_record_get_utf8_computer_name(
317
1.35k
           record,
318
1.35k
           utf8_string,
319
1.35k
           utf8_string_size,
320
1.35k
           NULL ) == 1 )
321
1.35k
      {
322
1.35k
        value_byte ^= utf8_string[ 0 ];
323
1.35k
      }
324
1.35k
      free( utf8_string );
325
1.35k
    }
326
1.35k
  }
327
  /* The size is the number of UTF-16 characters,
328
   * including the end of string character
329
   */
330
1.89k
  result = libevtx_record_get_utf16_computer_name_size(
331
1.89k
            record,
332
1.89k
            &utf16_string_size,
333
1.89k
            NULL );
334
335
1.89k
  if( ( result == 1 )
336
1.37k
   && ( utf16_string_size > 0 )
337
1.35k
   && ( utf16_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
338
1.35k
  {
339
1.35k
    utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
340
341
1.35k
    if( utf16_string != NULL )
342
1.35k
    {
343
1.35k
      if( libevtx_record_get_utf16_computer_name(
344
1.35k
           record,
345
1.35k
           utf16_string,
346
1.35k
           utf16_string_size,
347
1.35k
           NULL ) == 1 )
348
1.35k
      {
349
1.35k
        value_byte ^= (uint8_t) utf16_string[ 0 ];
350
1.35k
      }
351
1.35k
      free( utf16_string );
352
1.35k
    }
353
1.35k
  }
354
1.89k
  result = libevtx_record_get_utf8_user_security_identifier_size(
355
1.89k
            record,
356
1.89k
            &utf8_string_size,
357
1.89k
            NULL );
358
359
1.89k
  if( ( result == 1 )
360
200
   && ( utf8_string_size > 0 )
361
197
   && ( utf8_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
362
197
  {
363
197
    utf8_string = (uint8_t *) malloc( utf8_string_size );
364
365
197
    if( utf8_string != NULL )
366
197
    {
367
197
      if( libevtx_record_get_utf8_user_security_identifier(
368
197
           record,
369
197
           utf8_string,
370
197
           utf8_string_size,
371
197
           NULL ) == 1 )
372
197
      {
373
197
        value_byte ^= utf8_string[ 0 ];
374
197
      }
375
197
      free( utf8_string );
376
197
    }
377
197
  }
378
  /* The size is the number of UTF-16 characters,
379
   * including the end of string character
380
   */
381
1.89k
  result = libevtx_record_get_utf16_user_security_identifier_size(
382
1.89k
            record,
383
1.89k
            &utf16_string_size,
384
1.89k
            NULL );
385
386
1.89k
  if( ( result == 1 )
387
200
   && ( utf16_string_size > 0 )
388
197
   && ( utf16_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
389
197
  {
390
197
    utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
391
392
197
    if( utf16_string != NULL )
393
197
    {
394
197
      if( libevtx_record_get_utf16_user_security_identifier(
395
197
           record,
396
197
           utf16_string,
397
197
           utf16_string_size,
398
197
           NULL ) == 1 )
399
197
      {
400
197
        value_byte ^= (uint8_t) utf16_string[ 0 ];
401
197
      }
402
197
      free( utf16_string );
403
197
    }
404
197
  }
405
1.89k
  result = libevtx_record_get_number_of_strings(
406
1.89k
            record,
407
1.89k
            &number_of_strings,
408
1.89k
            NULL );
409
410
1.89k
  if( ( result == 1 )
411
1.38k
   && ( number_of_strings > 0 ) )
412
1.38k
  {
413
1.38k
    for( string_index = 0;
414
6.34k
         string_index < number_of_strings;
415
4.96k
         string_index++ )
416
5.10k
    {
417
5.10k
      if( string_index >= FUZZER_STRING_LIMIT )
418
139
      {
419
139
        break;
420
139
      }
421
4.96k
      result = libevtx_record_get_utf8_string_size(
422
4.96k
                record,
423
4.96k
                string_index,
424
4.96k
                &utf8_string_size,
425
4.96k
                NULL );
426
427
4.96k
      if( ( result == 1 )
428
4.95k
       && ( utf8_string_size > 0 )
429
4.89k
       && ( utf8_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
430
4.89k
      {
431
4.89k
        utf8_string = (uint8_t *) malloc( utf8_string_size );
432
433
4.89k
        if( utf8_string != NULL )
434
4.89k
        {
435
4.89k
          if( libevtx_record_get_utf8_string(
436
4.89k
               record,
437
4.89k
               string_index,
438
4.89k
               utf8_string,
439
4.89k
               utf8_string_size,
440
4.89k
               NULL ) == 1 )
441
4.89k
          {
442
4.89k
            value_byte ^= utf8_string[ 0 ];
443
4.89k
          }
444
4.89k
          free( utf8_string );
445
4.89k
        }
446
4.89k
      }
447
      /* The size is the number of UTF-16 characters,
448
       * including the end of string character
449
       */
450
4.96k
      result = libevtx_record_get_utf16_string_size(
451
4.96k
                record,
452
4.96k
                string_index,
453
4.96k
                &utf16_string_size,
454
4.96k
                NULL );
455
456
4.96k
      if( ( result == 1 )
457
4.95k
       && ( utf16_string_size > 0 )
458
4.89k
       && ( utf16_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
459
4.89k
      {
460
4.89k
        utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
461
462
4.89k
        if( utf16_string != NULL )
463
4.89k
        {
464
4.89k
          if( libevtx_record_get_utf16_string(
465
4.89k
               record,
466
4.89k
               string_index,
467
4.89k
               utf16_string,
468
4.89k
               utf16_string_size,
469
4.89k
               NULL ) == 1 )
470
4.89k
          {
471
4.89k
            value_byte ^= (uint8_t) utf16_string[ 0 ];
472
4.89k
          }
473
4.89k
          free( utf16_string );
474
4.89k
        }
475
4.89k
      }
476
4.96k
    }
477
1.38k
  }
478
  /* Note that not all record fields are present in a record
479
   */
480
1.89k
  result = libevtx_record_get_data_size(
481
1.89k
            record,
482
1.89k
            &data_size,
483
1.89k
            NULL );
484
485
1.89k
  if( ( result == 1 )
486
0
   && ( data_size > 0 )
487
0
   && ( data_size <= FUZZER_STRING_SIZE_LIMIT ) )
488
0
  {
489
0
    data_buffer = (uint8_t *) malloc( data_size );
490
491
0
    if( data_buffer != NULL )
492
0
    {
493
0
      if( libevtx_record_get_data(
494
0
           record,
495
0
           data_buffer,
496
0
           data_size,
497
0
           NULL ) == 1 )
498
0
      {
499
0
        value_byte ^= data_buffer[ 0 ];
500
0
      }
501
0
      free( data_buffer );
502
0
    }
503
0
  }
504
1.89k
  result = libevtx_record_get_utf8_xml_string_size(
505
1.89k
            record,
506
1.89k
            &utf8_string_size,
507
1.89k
            NULL );
508
509
1.89k
  if( ( result == 1 )
510
1.65k
   && ( utf8_string_size > 0 )
511
1.65k
   && ( utf8_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
512
1.64k
  {
513
1.64k
    utf8_string = (uint8_t *) malloc( utf8_string_size );
514
515
1.64k
    if( utf8_string != NULL )
516
1.64k
    {
517
1.64k
      if( libevtx_record_get_utf8_xml_string(
518
1.64k
           record,
519
1.64k
           utf8_string,
520
1.64k
           utf8_string_size,
521
1.64k
           NULL ) == 1 )
522
1.61k
      {
523
1.61k
        value_byte ^= utf8_string[ 0 ];
524
1.61k
      }
525
1.64k
      free( utf8_string );
526
1.64k
    }
527
1.64k
  }
528
  /* The size is the number of UTF-16 characters,
529
   * including the end of string character
530
   */
531
1.89k
  result = libevtx_record_get_utf16_xml_string_size(
532
1.89k
            record,
533
1.89k
            &utf16_string_size,
534
1.89k
            NULL );
535
536
1.89k
  if( ( result == 1 )
537
1.65k
   && ( utf16_string_size > 0 )
538
1.65k
   && ( utf16_string_size <= FUZZER_STRING_SIZE_LIMIT ) )
539
1.65k
  {
540
1.65k
    utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
541
542
1.65k
    if( utf16_string != NULL )
543
1.65k
    {
544
1.65k
      if( libevtx_record_get_utf16_xml_string(
545
1.65k
           record,
546
1.65k
           utf16_string,
547
1.65k
           utf16_string_size,
548
1.65k
           NULL ) == 1 )
549
1.62k
      {
550
1.62k
        value_byte ^= (uint8_t) utf16_string[ 0 ];
551
1.62k
      }
552
1.65k
      free( utf16_string );
553
1.65k
    }
554
1.65k
  }
555
  /* Use the decoded values as a sink to keep them live
556
   */
557
1.89k
  if( ( value_byte ^ (uint8_t) identifier ^ (uint8_t) offset ) != 0 )
558
1.88k
  {
559
    /* No action required
560
     */
561
1.88k
  }
562
1.89k
  return( 1 );
563
1.89k
}
564
565
int LLVMFuzzerTestOneInput(
566
      const uint8_t *data,
567
      size_t size )
568
3.13k
{
569
3.13k
  libbfio_handle_t *file_io_handle = NULL;
570
3.13k
  libevtx_file_t *file             = NULL;
571
3.13k
  libevtx_record_t *record         = NULL;
572
3.13k
  int number_of_records            = 0;
573
3.13k
  int record_index                 = 0;
574
3.13k
  int result                       = 0;
575
576
3.13k
  if( libbfio_memory_range_initialize(
577
3.13k
       &file_io_handle,
578
3.13k
       NULL ) != 1 )
579
0
  {
580
0
    return( 0 );
581
0
  }
582
3.13k
  if( libbfio_memory_range_set(
583
3.13k
       file_io_handle,
584
3.13k
       (uint8_t *) data,
585
3.13k
       size,
586
3.13k
       NULL ) != 1 )
587
0
  {
588
0
    goto on_error_libbfio;
589
0
  }
590
3.13k
  if( libevtx_file_initialize(
591
3.13k
       &file,
592
3.13k
       NULL ) != 1 )
593
0
  {
594
0
    goto on_error_libbfio;
595
0
  }
596
3.13k
  if( libevtx_file_open_file_io_handle(
597
3.13k
       file,
598
3.13k
       file_io_handle,
599
3.13k
       LIBEVTX_OPEN_READ,
600
3.13k
       NULL ) != 1 )
601
216
  {
602
216
    goto on_error_libevtx_file;
603
216
  }
604
  /* The codepage is selected from the fuzz data to steer the
605
   * codepage conversion of the record values
606
   */
607
2.91k
  if( size > 0 )
608
2.91k
  {
609
2.91k
    libevtx_file_set_ascii_codepage(
610
2.91k
     file,
611
2.91k
     file_codepages[ data[ 0 ] % file_number_of_codepages ],
612
2.91k
     NULL );
613
2.91k
  }
614
2.91k
  result = libevtx_file_get_number_of_records(
615
2.91k
            file,
616
2.91k
            &number_of_records,
617
2.91k
            NULL );
618
619
2.91k
  if( ( result == 1 )
620
2.91k
   && ( number_of_records > 0 ) )
621
2.47k
  {
622
2.47k
    for( record_index = 0;
623
7.57k
         record_index < number_of_records;
624
5.10k
         record_index++ )
625
5.52k
    {
626
5.52k
      if( record_index >= FUZZER_RECORD_LIMIT )
627
424
      {
628
424
        break;
629
424
      }
630
5.10k
      record = NULL;
631
632
5.10k
      if( libevtx_file_get_record_by_index(
633
5.10k
           file,
634
5.10k
           record_index,
635
5.10k
           &record,
636
5.10k
           NULL ) != 1 )
637
3.21k
      {
638
3.21k
        continue;
639
3.21k
      }
640
1.89k
      record_decode_fuzzer(
641
1.89k
       record );
642
643
1.89k
      libevtx_record_free(
644
1.89k
       &record,
645
1.89k
       NULL );
646
1.89k
    }
647
2.47k
  }
648
2.91k
  libevtx_file_close(
649
2.91k
   file,
650
2.91k
   NULL );
651
652
3.13k
on_error_libevtx_file:
653
3.13k
  libevtx_file_free(
654
3.13k
   &file,
655
3.13k
   NULL );
656
657
3.13k
on_error_libbfio:
658
3.13k
  libbfio_handle_free(
659
3.13k
   &file_io_handle,
660
3.13k
   NULL );
661
662
3.13k
  return( 0 );
663
3.13k
}
664
665
} /* extern "C" */