Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libnk2/ossfuzz/record_fuzzer.cc
Line
Count
Source
1
/*
2
 * OSS-Fuzz target for the libnk2 record entry type
3
 *
4
 * Copyright (C) 2009-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
#include <stdlib.h>
25
26
/* Note that some of the OSS-Fuzz engines use C++
27
 */
28
extern "C" {
29
30
#include "ossfuzz_libbfio.h"
31
#include "ossfuzz_libnk2.h"
32
33
#if !defined( LIBNK2_HAVE_BFIO )
34
35
/* Opens a file using a Basic File IO (bfio) handle
36
 * Returns 1 if successful or -1 on error
37
 */
38
LIBNK2_EXTERN \
39
int libnk2_file_open_file_io_handle(
40
      libnk2_file_t *file,
41
      libbfio_handle_t *file_io_handle,
42
      int access_flags,
43
      libnk2_error_t **error );
44
45
#endif /* !defined( LIBNK2_HAVE_BFIO ) */
46
47
/* Used to limit the amount of memory the fuzzer will allocate
48
 */
49
26.1k
#define MAXIMUM_ALLOCATION_SIZE ( 1024 * 1024 )
50
51
/* Used to limit the number of items and entries that are exercised
52
 */
53
679
#define NUMBER_OF_ITEMS_TO_EXERCISE 64
54
4.10k
#define NUMBER_OF_ENTRIES_TO_EXERCISE 64
55
56
1.17k
#define NUMBER_OF_CODEPAGES 16
57
58
/* The codepages supported by libnk2_file_set_ascii_codepage
59
 * The value 0 represents an unsupported codepage
60
 * which is used to exercise the error path
61
 */
62
const int codepages[ NUMBER_OF_CODEPAGES ] = {
63
  0,
64
  LIBNK2_CODEPAGE_WINDOWS_874,
65
  LIBNK2_CODEPAGE_WINDOWS_932,
66
  LIBNK2_CODEPAGE_WINDOWS_936,
67
  LIBNK2_CODEPAGE_WINDOWS_949,
68
  LIBNK2_CODEPAGE_WINDOWS_950,
69
  LIBNK2_CODEPAGE_WINDOWS_1250,
70
  LIBNK2_CODEPAGE_WINDOWS_1251,
71
  LIBNK2_CODEPAGE_WINDOWS_1252,
72
  LIBNK2_CODEPAGE_WINDOWS_1253,
73
  LIBNK2_CODEPAGE_WINDOWS_1254,
74
  LIBNK2_CODEPAGE_WINDOWS_1255,
75
  LIBNK2_CODEPAGE_WINDOWS_1256,
76
  LIBNK2_CODEPAGE_WINDOWS_1257,
77
  LIBNK2_CODEPAGE_WINDOWS_1258,
78
  LIBNK2_CODEPAGE_ASCII
79
};
80
81
/* Retrieves the UTF-8 encoded string from a record entry
82
 * using a pair of getter functions
83
 */
84
void fuzzer_record_entry_fetch_utf8_string(
85
      libnk2_record_entry_t *record_entry )
86
19.0k
{
87
19.0k
  uint8_t *utf8_string    = NULL;
88
19.0k
  size_t utf8_string_size = 0;
89
90
19.0k
  if( record_entry == NULL )
91
0
  {
92
0
    return;
93
0
  }
94
19.0k
  if( libnk2_record_entry_get_data_as_utf8_string_size(
95
19.0k
        record_entry,
96
19.0k
        &utf8_string_size,
97
19.0k
        NULL ) != 1 )
98
14.7k
  {
99
14.7k
    return;
100
14.7k
  }
101
4.29k
  if( ( utf8_string_size == 0 )
102
4.15k
   || ( utf8_string_size > MAXIMUM_ALLOCATION_SIZE ) )
103
140
  {
104
140
    return;
105
140
  }
106
4.15k
  utf8_string = (uint8_t *) malloc( utf8_string_size );
107
108
4.15k
  if( utf8_string == NULL )
109
0
  {
110
0
    return;
111
0
  }
112
4.15k
  libnk2_record_entry_get_data_as_utf8_string(
113
4.15k
   record_entry,
114
4.15k
   utf8_string,
115
4.15k
   utf8_string_size,
116
4.15k
   NULL );
117
118
  /* Tests the string size value out of bounds error branch
119
   */
120
4.15k
  libnk2_record_entry_get_data_as_utf8_string(
121
4.15k
   record_entry,
122
4.15k
   utf8_string,
123
4.15k
   0,
124
4.15k
   NULL );
125
4.15k
  free( utf8_string );
126
4.15k
}
127
128
/* Retrieves the UTF-16 encoded string from a record entry
129
 * using a pair of getter functions
130
 */
131
void fuzzer_record_entry_fetch_utf16_string(
132
      libnk2_record_entry_t *record_entry )
133
19.0k
{
134
19.0k
  uint16_t *utf16_string   = NULL;
135
19.0k
  size_t utf16_string_size = 0;
136
137
19.0k
  if( record_entry == NULL )
138
0
  {
139
0
    return;
140
0
  }
141
19.0k
  if( libnk2_record_entry_get_data_as_utf16_string_size(
142
19.0k
        record_entry,
143
19.0k
        &utf16_string_size,
144
19.0k
        NULL ) != 1 )
145
14.7k
  {
146
14.7k
    return;
147
14.7k
  }
148
4.29k
  if( ( utf16_string_size == 0 )
149
4.15k
   || ( utf16_string_size > ( MAXIMUM_ALLOCATION_SIZE / sizeof( uint16_t ) ) ) )
150
140
  {
151
140
    return;
152
140
  }
153
4.15k
  utf16_string = (uint16_t *) malloc( utf16_string_size * sizeof( uint16_t ) );
154
155
4.15k
  if( utf16_string == NULL )
156
0
  {
157
0
    return;
158
0
  }
159
4.15k
  libnk2_record_entry_get_data_as_utf16_string(
160
4.15k
   record_entry,
161
4.15k
   utf16_string,
162
4.15k
   utf16_string_size,
163
4.15k
   NULL );
164
165
  /* Tests the string size value out of bounds error branch
166
   */
167
4.15k
  libnk2_record_entry_get_data_as_utf16_string(
168
4.15k
   record_entry,
169
4.15k
   utf16_string,
170
4.15k
   0,
171
4.15k
   NULL );
172
4.15k
  free( utf16_string );
173
4.15k
}
174
175
/* Tests the getter functions of a record entry
176
 */
177
void fuzzer_record_entry_exercise_getters(
178
      libnk2_record_entry_t *record_entry )
179
8.91k
{
180
8.91k
  uint8_t value_boolean   = 0;
181
8.91k
  uint8_t guid_data[ 16 ] = { 0 };
182
8.91k
  uint16_t value_16bit    = 0;
183
8.91k
  uint32_t value_32bit    = 0;
184
8.91k
  uint64_t value_64bit    = 0;
185
8.91k
  uint8_t *data           = NULL;
186
8.91k
  size64_t value_size     = 0;
187
8.91k
  size_t data_size        = 0;
188
8.91k
  double value_floating_point = 0.0;
189
8.91k
  int result              = 0;
190
191
8.91k
  if( record_entry == NULL )
192
0
  {
193
0
    return;
194
0
  }
195
8.91k
  libnk2_record_entry_get_entry_type(
196
8.91k
   record_entry,
197
8.91k
   &( value_32bit ),
198
8.91k
   NULL );
199
200
8.91k
  libnk2_record_entry_get_value_type(
201
8.91k
   record_entry,
202
8.91k
   &( value_32bit ),
203
8.91k
   NULL );
204
205
8.91k
  result = libnk2_record_entry_get_data_size(
206
8.91k
            record_entry,
207
8.91k
            &data_size,
208
8.91k
            NULL );
209
210
8.91k
  if( ( result == 1 )
211
8.91k
   && ( data_size <= MAXIMUM_ALLOCATION_SIZE ) )
212
8.91k
  {
213
8.91k
    data = (uint8_t *) malloc(
214
8.91k
                  data_size < 1 ? 1 : data_size );
215
216
8.91k
    if( data != NULL )
217
8.91k
    {
218
8.91k
      libnk2_record_entry_get_data(
219
8.91k
       record_entry,
220
8.91k
       data,
221
8.91k
       data_size,
222
8.91k
       NULL );
223
8.91k
      free( data );
224
8.91k
    }
225
8.91k
  }
226
  /* Tests the data size value out of bounds error branch
227
   */
228
8.91k
  if( ( result == 1 )
229
8.91k
   && ( data_size <= MAXIMUM_ALLOCATION_SIZE ) )
230
8.91k
  {
231
8.91k
    data = (uint8_t *) malloc( 1 );
232
233
8.91k
    if( data != NULL )
234
8.91k
    {
235
8.91k
      libnk2_record_entry_get_data(
236
8.91k
       record_entry,
237
8.91k
       data,
238
8.91k
       0,
239
8.91k
       NULL );
240
8.91k
      free( data );
241
8.91k
    }
242
8.91k
  }
243
8.91k
  libnk2_record_entry_get_data_as_boolean(
244
8.91k
   record_entry,
245
8.91k
   &value_boolean,
246
8.91k
   NULL );
247
248
8.91k
  libnk2_record_entry_get_data_as_16bit_integer(
249
8.91k
   record_entry,
250
8.91k
   &value_16bit,
251
8.91k
   NULL );
252
253
8.91k
  libnk2_record_entry_get_data_as_32bit_integer(
254
8.91k
   record_entry,
255
8.91k
   &value_32bit,
256
8.91k
   NULL );
257
258
8.91k
  libnk2_record_entry_get_data_as_64bit_integer(
259
8.91k
   record_entry,
260
8.91k
   &value_64bit,
261
8.91k
   NULL );
262
263
8.91k
  libnk2_record_entry_get_data_as_filetime(
264
8.91k
   record_entry,
265
8.91k
   &value_64bit,
266
8.91k
   NULL );
267
268
8.91k
  libnk2_record_entry_get_data_as_floatingtime(
269
8.91k
   record_entry,
270
8.91k
   &value_64bit,
271
8.91k
   NULL );
272
273
8.91k
  libnk2_record_entry_get_data_as_size(
274
8.91k
   record_entry,
275
8.91k
   &value_size,
276
8.91k
   NULL );
277
278
8.91k
  libnk2_record_entry_get_data_as_floating_point(
279
8.91k
   record_entry,
280
8.91k
   &value_floating_point,
281
8.91k
   NULL );
282
283
8.91k
  fuzzer_record_entry_fetch_utf8_string(
284
8.91k
   record_entry );
285
286
8.91k
  fuzzer_record_entry_fetch_utf16_string(
287
8.91k
   record_entry );
288
289
8.91k
  libnk2_record_entry_get_data_as_guid(
290
8.91k
   record_entry,
291
8.91k
   guid_data,
292
8.91k
   sizeof( guid_data ),
293
8.91k
   NULL );
294
295
  /* Tests the GUID data size value too small error branch
296
   */
297
8.91k
  libnk2_record_entry_get_data_as_guid(
298
8.91k
   record_entry,
299
8.91k
   guid_data,
300
8.91k
   8,
301
8.91k
   NULL );
302
8.91k
}
303
304
/* Tests the invalid output getter functions of a record entry
305
 */
306
void fuzzer_record_entry_exercise_invalid_output(
307
      libnk2_record_entry_t *record_entry )
308
8.91k
{
309
8.91k
  if( record_entry == NULL )
310
0
  {
311
0
    return;
312
0
  }
313
8.91k
  libnk2_record_entry_get_entry_type(
314
8.91k
   record_entry,
315
8.91k
   NULL,
316
8.91k
   NULL );
317
318
8.91k
  libnk2_record_entry_get_value_type(
319
8.91k
   record_entry,
320
8.91k
   NULL,
321
8.91k
   NULL );
322
323
8.91k
  libnk2_record_entry_get_data_size(
324
8.91k
   record_entry,
325
8.91k
   NULL,
326
8.91k
   NULL );
327
328
8.91k
  libnk2_record_entry_get_data(
329
8.91k
   record_entry,
330
8.91k
   NULL,
331
8.91k
   8,
332
8.91k
   NULL );
333
334
8.91k
  libnk2_record_entry_get_data_as_boolean(
335
8.91k
   record_entry,
336
8.91k
   NULL,
337
8.91k
   NULL );
338
339
8.91k
  libnk2_record_entry_get_data_as_16bit_integer(
340
8.91k
   record_entry,
341
8.91k
   NULL,
342
8.91k
   NULL );
343
344
8.91k
  libnk2_record_entry_get_data_as_32bit_integer(
345
8.91k
   record_entry,
346
8.91k
   NULL,
347
8.91k
   NULL );
348
349
8.91k
  libnk2_record_entry_get_data_as_64bit_integer(
350
8.91k
   record_entry,
351
8.91k
   NULL,
352
8.91k
   NULL );
353
354
8.91k
  libnk2_record_entry_get_data_as_filetime(
355
8.91k
   record_entry,
356
8.91k
   NULL,
357
8.91k
   NULL );
358
359
8.91k
  libnk2_record_entry_get_data_as_floatingtime(
360
8.91k
   record_entry,
361
8.91k
   NULL,
362
8.91k
   NULL );
363
364
8.91k
  libnk2_record_entry_get_data_as_size(
365
8.91k
   record_entry,
366
8.91k
   NULL,
367
8.91k
   NULL );
368
369
8.91k
  libnk2_record_entry_get_data_as_floating_point(
370
8.91k
   record_entry,
371
8.91k
   NULL,
372
8.91k
   NULL );
373
374
8.91k
  libnk2_record_entry_get_data_as_utf8_string_size(
375
8.91k
   record_entry,
376
8.91k
   NULL,
377
8.91k
   NULL );
378
379
8.91k
  libnk2_record_entry_get_data_as_utf16_string_size(
380
8.91k
   record_entry,
381
8.91k
   NULL,
382
8.91k
   NULL );
383
384
8.91k
  libnk2_record_entry_get_data_as_guid(
385
8.91k
   record_entry,
386
8.91k
   NULL,
387
8.91k
   sizeof( uint8_t ) * 16,
388
8.91k
   NULL );
389
8.91k
}
390
391
/* Tests the getter functions of an item
392
 */
393
void fuzzer_item_exercise(
394
      libnk2_item_t *item )
395
4.09k
{
396
4.09k
  libnk2_record_entry_t *record_entry = NULL;
397
4.09k
  int number_of_entries               = 0;
398
4.09k
  int entry_index                     = 0;
399
4.09k
  int result                          = 0;
400
401
4.09k
  if( item == NULL )
402
0
  {
403
0
    return;
404
0
  }
405
4.09k
  result = libnk2_item_get_number_of_entries(
406
4.09k
            item,
407
4.09k
            &number_of_entries,
408
4.09k
            NULL );
409
410
  /* Tests the invalid output getter functions of an item
411
   */
412
4.09k
  if( result != 1 )
413
0
  {
414
0
    number_of_entries = 0;
415
0
  }
416
4.09k
  libnk2_item_get_number_of_entries(
417
4.09k
   item,
418
4.09k
   NULL,
419
4.09k
   NULL );
420
421
  /* Tests the invalid output getter functions of an item
422
   */
423
4.09k
  libnk2_item_get_entry_by_index(
424
4.09k
   item,
425
4.09k
   0,
426
4.09k
   NULL,
427
4.09k
   NULL );
428
429
4.09k
  record_entry = (libnk2_record_entry_t *) 0x12345678UL;
430
431
4.09k
  libnk2_item_get_entry_by_index(
432
4.09k
   item,
433
4.09k
   0,
434
4.09k
   &record_entry,
435
4.09k
   NULL );
436
437
4.09k
  record_entry = NULL;
438
439
4.09k
  if( number_of_entries > 0 )
440
4.09k
  {
441
4.09k
    entry_index = number_of_entries;
442
443
4.09k
    libnk2_item_get_entry_by_index(
444
4.09k
     item,
445
4.09k
     entry_index,
446
4.09k
     &record_entry,
447
4.09k
     NULL );
448
449
4.09k
    entry_index = -1;
450
451
4.09k
    libnk2_item_get_entry_by_index(
452
4.09k
     item,
453
4.09k
     entry_index,
454
4.09k
     &record_entry,
455
4.09k
     NULL );
456
4.09k
  }
457
4.09k
  if( number_of_entries > NUMBER_OF_ENTRIES_TO_EXERCISE )
458
10
  {
459
10
    number_of_entries = NUMBER_OF_ENTRIES_TO_EXERCISE;
460
10
  }
461
4.09k
  for( entry_index = 0;
462
10.1k
       entry_index < number_of_entries;
463
6.04k
       entry_index++ )
464
6.04k
  {
465
6.04k
    record_entry = NULL;
466
467
6.04k
    result = libnk2_item_get_entry_by_index(
468
6.04k
              item,
469
6.04k
              entry_index,
470
6.04k
              &record_entry,
471
6.04k
              NULL );
472
473
6.04k
    if( ( result == 1 )
474
6.04k
     && ( record_entry != NULL ) )
475
6.04k
    {
476
6.04k
      fuzzer_record_entry_exercise_getters(
477
6.04k
       record_entry );
478
479
6.04k
      fuzzer_record_entry_exercise_invalid_output(
480
6.04k
       record_entry );
481
482
6.04k
      libnk2_record_entry_free(
483
6.04k
       &record_entry,
484
6.04k
       NULL );
485
6.04k
    }
486
6.04k
  }
487
  /* Tests the invalid output and unsupported flags of an item
488
   */
489
4.09k
  libnk2_item_get_entry_by_type(
490
4.09k
   item,
491
4.09k
   LIBNK2_ENTRY_TYPE_DISPLAY_NAME,
492
4.09k
   LIBNK2_VALUE_TYPE_STRING_UNICODE,
493
4.09k
   NULL,
494
4.09k
   0,
495
4.09k
   NULL );
496
497
4.09k
  record_entry = (libnk2_record_entry_t *) 0x12345678UL;
498
499
4.09k
  libnk2_item_get_entry_by_type(
500
4.09k
   item,
501
4.09k
   LIBNK2_ENTRY_TYPE_DISPLAY_NAME,
502
4.09k
   LIBNK2_VALUE_TYPE_STRING_UNICODE,
503
4.09k
   &record_entry,
504
4.09k
   0,
505
4.09k
   NULL );
506
507
4.09k
  record_entry = NULL;
508
509
4.09k
  libnk2_item_get_entry_by_type(
510
4.09k
   item,
511
4.09k
   LIBNK2_ENTRY_TYPE_DISPLAY_NAME,
512
4.09k
   LIBNK2_VALUE_TYPE_STRING_UNICODE,
513
4.09k
   &record_entry,
514
4.09k
   0x80,
515
4.09k
   NULL );
516
517
4.09k
  record_entry = NULL;
518
519
4.09k
  result = libnk2_item_get_entry_by_type(
520
4.09k
            item,
521
4.09k
            LIBNK2_ENTRY_TYPE_DISPLAY_NAME,
522
4.09k
            LIBNK2_VALUE_TYPE_STRING_UNICODE,
523
4.09k
            &record_entry,
524
4.09k
            0,
525
4.09k
            NULL );
526
527
4.09k
  if( ( result == 1 )
528
1.00k
   && ( record_entry != NULL ) )
529
1.00k
  {
530
1.00k
    fuzzer_record_entry_exercise_getters(
531
1.00k
     record_entry );
532
533
1.00k
    fuzzer_record_entry_exercise_invalid_output(
534
1.00k
     record_entry );
535
536
1.00k
    libnk2_record_entry_free(
537
1.00k
     &record_entry,
538
1.00k
     NULL );
539
1.00k
  }
540
4.09k
  record_entry = NULL;
541
542
4.09k
  result = libnk2_item_get_entry_by_type(
543
4.09k
            item,
544
4.09k
            LIBNK2_ENTRY_TYPE_RECIPIENT_TYPE,
545
4.09k
            LIBNK2_VALUE_TYPE_UNSPECIFIED,
546
4.09k
            &record_entry,
547
4.09k
            LIBNK2_ENTRY_VALUE_FLAG_MATCH_ANY_VALUE_TYPE,
548
4.09k
            NULL );
549
550
4.09k
  if( ( result == 1 )
551
1.87k
   && ( record_entry != NULL ) )
552
1.87k
  {
553
1.87k
    fuzzer_record_entry_exercise_getters(
554
1.87k
     record_entry );
555
556
1.87k
    fuzzer_record_entry_exercise_invalid_output(
557
1.87k
     record_entry );
558
559
1.87k
    libnk2_record_entry_free(
560
1.87k
     &record_entry,
561
1.87k
     NULL );
562
1.87k
  }
563
4.09k
}
564
565
int LLVMFuzzerTestOneInput(
566
      const uint8_t *data,
567
      size_t size )
568
1.17k
{
569
1.17k
  libbfio_handle_t *file_io_handle = NULL;
570
1.17k
  libnk2_file_t *file              = NULL;
571
1.17k
  libnk2_item_t *item              = NULL;
572
1.17k
  uint64_t filetime                = 0;
573
1.17k
  int codepage                     = 0;
574
1.17k
  int number_of_items              = 0;
575
1.17k
  int item_index                   = 0;
576
1.17k
  int result                       = 0;
577
578
1.17k
  if( libbfio_memory_range_initialize(
579
1.17k
       &file_io_handle,
580
1.17k
       NULL ) != 1 )
581
0
  {
582
0
    return( 0 );
583
0
  }
584
1.17k
  if( libbfio_memory_range_set(
585
1.17k
       file_io_handle,
586
1.17k
       (uint8_t *) data,
587
1.17k
       size,
588
1.17k
       NULL ) != 1 )
589
0
  {
590
0
    goto on_error_libbfio;
591
0
  }
592
1.17k
  if( libnk2_file_initialize(
593
1.17k
       &file,
594
1.17k
       NULL ) != 1 )
595
0
  {
596
0
    goto on_error_libbfio;
597
0
  }
598
1.17k
  if( size > 0 )
599
1.17k
  {
600
1.17k
    codepage = codepages[ (int) ( data[ 0 ] % NUMBER_OF_CODEPAGES ) ];
601
1.17k
  }
602
0
  else
603
0
  {
604
0
    codepage = codepages[ 1 ];
605
0
  }
606
1.17k
  if( libnk2_file_set_ascii_codepage(
607
1.17k
       file,
608
1.17k
       codepage,
609
1.17k
       NULL ) != 1 )
610
4
  {
611
4
    codepage = LIBNK2_CODEPAGE_WINDOWS_1252;
612
4
  }
613
1.17k
  result = libnk2_file_open_file_io_handle(
614
1.17k
            file,
615
1.17k
            file_io_handle,
616
1.17k
            LIBNK2_ACCESS_FLAG_READ,
617
1.17k
            NULL );
618
619
1.17k
  if( result == 1 )
620
674
  {
621
674
    libnk2_file_get_modification_time(
622
674
     file,
623
674
     &filetime,
624
674
     NULL );
625
626
674
    result = libnk2_file_get_number_of_items(
627
674
              file,
628
674
              &number_of_items,
629
674
              NULL );
630
631
674
    if( result != 1 )
632
0
    {
633
0
      number_of_items = 0;
634
0
    }
635
674
    if( number_of_items > NUMBER_OF_ITEMS_TO_EXERCISE )
636
5
    {
637
5
      number_of_items = NUMBER_OF_ITEMS_TO_EXERCISE;
638
5
    }
639
674
    for( item_index = 0;
640
4.77k
         item_index < number_of_items;
641
4.09k
         item_index++ )
642
4.09k
    {
643
4.09k
      item = NULL;
644
645
4.09k
      result = libnk2_file_get_item(
646
4.09k
                file,
647
4.09k
                item_index,
648
4.09k
                &item,
649
4.09k
                NULL );
650
651
4.09k
      if( ( result == 1 )
652
4.09k
       && ( item != NULL ) )
653
4.09k
      {
654
4.09k
        fuzzer_item_exercise(
655
4.09k
         item );
656
657
4.09k
        libnk2_item_free(
658
4.09k
         &item,
659
4.09k
         NULL );
660
4.09k
      }
661
4.09k
    }
662
674
    libnk2_file_close(
663
674
     file,
664
674
     NULL );
665
674
  }
666
1.17k
  result = libnk2_file_free(
667
1.17k
            &file,
668
1.17k
            NULL );
669
670
1.17k
  if( result != 1 )
671
0
  {
672
0
    goto on_error_libbfio;
673
0
  }
674
1.17k
on_error_libbfio:
675
1.17k
  libbfio_handle_free(
676
1.17k
   &file_io_handle,
677
1.17k
   NULL );
678
679
1.17k
  return( 0 );
680
1.17k
}
681
682
} /* extern "C" */