Coverage Report

Created: 2025-06-24 07:14

/src/libmodi/libmodi/libmodi_data_block.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Data block functions
3
 *
4
 * Copyright (C) 2012-2024, 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 <common.h>
23
#include <byte_stream.h>
24
#include <memory.h>
25
#include <types.h>
26
27
#include "libmodi_compression.h"
28
#include "libmodi_data_block.h"
29
#include "libmodi_definitions.h"
30
#include "libmodi_io_handle.h"
31
#include "libmodi_libbfio.h"
32
#include "libmodi_libcerror.h"
33
#include "libmodi_libcnotify.h"
34
#include "libmodi_libfdata.h"
35
#include "libmodi_unused.h"
36
37
/* Creates a data block
38
 * Make sure the value data_block is referencing, is set to NULL
39
 * Returns 1 if successful or -1 on error
40
 */
41
int libmodi_data_block_initialize(
42
     libmodi_data_block_t **data_block,
43
     size_t data_size,
44
     libcerror_error_t **error )
45
0
{
46
0
  static char *function = "libmodi_data_block_initialize";
47
48
0
  if( data_block == NULL )
49
0
  {
50
0
    libcerror_error_set(
51
0
     error,
52
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
53
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
54
0
     "%s: invalid data block.",
55
0
     function );
56
57
0
    return( -1 );
58
0
  }
59
0
  if( *data_block != NULL )
60
0
  {
61
0
    libcerror_error_set(
62
0
     error,
63
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
64
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
65
0
     "%s: invalid data block value already set.",
66
0
     function );
67
68
0
    return( -1 );
69
0
  }
70
0
  if( ( data_size == 0 )
71
0
   || ( data_size > (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
72
0
  {
73
0
    libcerror_error_set(
74
0
     error,
75
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
76
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
77
0
     "%s: invalid data size value out of bounds.",
78
0
     function );
79
80
0
    return( -1 );
81
0
  }
82
0
  *data_block = memory_allocate_structure(
83
0
                 libmodi_data_block_t );
84
85
0
  if( *data_block == NULL )
86
0
  {
87
0
    libcerror_error_set(
88
0
     error,
89
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
90
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
91
0
     "%s: unable to create data block.",
92
0
     function );
93
94
0
    goto on_error;
95
0
  }
96
0
  if( memory_set(
97
0
       *data_block,
98
0
       0,
99
0
       sizeof( libmodi_data_block_t ) ) == NULL )
100
0
  {
101
0
    libcerror_error_set(
102
0
     error,
103
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
104
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
105
0
     "%s: unable to clear data block.",
106
0
     function );
107
108
0
    memory_free(
109
0
     *data_block );
110
111
0
    *data_block = NULL;
112
113
0
    return( -1 );
114
0
  }
115
0
  ( *data_block )->data = (uint8_t *) memory_allocate(
116
0
                                       sizeof( uint8_t ) * data_size );
117
118
0
  if( ( *data_block )->data == NULL )
119
0
  {
120
0
    libcerror_error_set(
121
0
     error,
122
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
123
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
124
0
     "%s: unable to create data.",
125
0
     function );
126
127
0
    goto on_error;
128
0
  }
129
0
  ( *data_block )->data_size = data_size;
130
131
0
  return( 1 );
132
133
0
on_error:
134
0
  if( *data_block != NULL )
135
0
  {
136
0
    memory_free(
137
0
     *data_block );
138
139
0
    *data_block = NULL;
140
0
  }
141
0
  return( -1 );
142
0
}
143
144
/* Frees a data block
145
 * Returns 1 if successful or -1 on error
146
 */
147
int libmodi_data_block_free(
148
     libmodi_data_block_t **data_block,
149
     libcerror_error_t **error )
150
0
{
151
0
  static char *function = "libmodi_data_block_free";
152
0
  int result            = 1;
153
154
0
  if( data_block == NULL )
155
0
  {
156
0
    libcerror_error_set(
157
0
     error,
158
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
159
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
160
0
     "%s: invalid data block.",
161
0
     function );
162
163
0
    return( -1 );
164
0
  }
165
0
  if( *data_block != NULL )
166
0
  {
167
0
    memory_free(
168
0
     ( *data_block )->data );
169
170
0
    memory_free(
171
0
     *data_block );
172
173
0
    *data_block = NULL;
174
0
  }
175
0
  return( result );
176
0
}
177
178
/* Clears a data block
179
 * Returns 1 if successful or -1 on error
180
 */
181
int libmodi_data_block_clear(
182
     libmodi_data_block_t *data_block,
183
     libcerror_error_t **error )
184
0
{
185
0
  static char *function = "libmodi_data_block_clear";
186
187
0
  if( data_block == NULL )
188
0
  {
189
0
    libcerror_error_set(
190
0
     error,
191
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
192
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
193
0
     "%s: invalid data block.",
194
0
     function );
195
196
0
    return( -1 );
197
0
  }
198
0
  if( data_block->data == NULL )
199
0
  {
200
0
    libcerror_error_set(
201
0
     error,
202
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
203
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
204
0
     "%s: invalid data block - missing data.",
205
0
     function );
206
207
0
    return( -1 );
208
0
  }
209
0
  if( memory_set(
210
0
       data_block->data,
211
0
       0,
212
0
       data_block->data_size ) == NULL )
213
0
  {
214
0
    libcerror_error_set(
215
0
     error,
216
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
217
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
218
0
     "%s: unable to clear data block data.",
219
0
     function );
220
221
0
    return( -1 );
222
0
  }
223
0
  return( 1 );
224
0
}
225
226
/* Reads data block
227
 * Returns 1 if successful or -1 on error
228
 */
229
int libmodi_data_block_read_file_io_handle(
230
     libmodi_data_block_t *data_block,
231
     libbfio_handle_t *file_io_handle,
232
     off64_t data_block_offset,
233
     libcerror_error_t **error )
234
0
{
235
0
  static char *function = "libmodi_data_block_read_file_io_handle";
236
0
  ssize_t read_count    = 0;
237
238
0
  if( data_block == NULL )
239
0
  {
240
0
    libcerror_error_set(
241
0
     error,
242
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
243
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
244
0
     "%s: invalid data block.",
245
0
     function );
246
247
0
    return( -1 );
248
0
  }
249
#if defined( HAVE_DEBUG_OUTPUT )
250
  if( libcnotify_verbose != 0 )
251
  {
252
    libcnotify_printf(
253
     "%s: reading data block at offset: %" PRIi64 " (0x%08" PRIx64 ")\n",
254
     function,
255
     data_block_offset,
256
     data_block_offset );
257
  }
258
#endif
259
0
  read_count = libbfio_handle_read_buffer_at_offset(
260
0
                file_io_handle,
261
0
                data_block->data,
262
0
                data_block->data_size,
263
0
                data_block_offset,
264
0
                error );
265
266
0
  if( read_count != (ssize_t) data_block->data_size )
267
0
  {
268
0
    libcerror_error_set(
269
0
     error,
270
0
     LIBCERROR_ERROR_DOMAIN_IO,
271
0
     LIBCERROR_IO_ERROR_READ_FAILED,
272
0
     "%s: unable to read data block at offset: %" PRIi64 " (0x%08" PRIx64 ").",
273
0
     function,
274
0
     data_block_offset,
275
0
     data_block_offset );
276
277
0
    return( -1 );
278
0
  }
279
#if defined( HAVE_DEBUG_OUTPUT )
280
  if( libcnotify_verbose != 0 )
281
  {
282
    libcnotify_printf(
283
     "%s: data block:\n",
284
     function );
285
    libcnotify_print_data(
286
     data_block->data,
287
     data_block->data_size,
288
     LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
289
  }
290
#endif
291
0
  return( 1 );
292
0
}
293
294
/* Reads a data block
295
 * Callback function for the block chunks list
296
 * Returns 1 if successful or -1 on error
297
 */
298
int libmodi_data_block_read_list_element_data(
299
     libmodi_io_handle_t *io_handle,
300
     libbfio_handle_t *file_io_handle,
301
     libfdata_list_element_t *element,
302
     libfdata_cache_t *cache,
303
     int element_data_file_index LIBMODI_ATTRIBUTE_UNUSED,
304
     off64_t element_data_offset,
305
     size64_t element_data_size,
306
     uint32_t element_data_flags,
307
     uint8_t read_flags LIBMODI_ATTRIBUTE_UNUSED,
308
     libcerror_error_t **error )
309
0
{
310
0
  libmodi_data_block_t *data_block = NULL;
311
0
  static char *function            = "libmodi_data_block_read_list_element_data";
312
0
  uint8_t *compressed_data         = NULL;
313
0
  size64_t mapped_size             = 0;
314
0
  size_t uncompressed_data_size    = 0;
315
0
  ssize_t read_count               = 0;
316
317
0
  LIBMODI_UNREFERENCED_PARAMETER( element_data_file_index )
318
0
  LIBMODI_UNREFERENCED_PARAMETER( read_flags )
319
320
0
  if( io_handle == NULL )
321
0
  {
322
0
    libcerror_error_set(
323
0
     error,
324
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
325
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
326
0
     "%s: invalid IO handle.",
327
0
     function );
328
329
0
    return( -1 );
330
0
  }
331
0
  if( ( element_data_flags & LIBFDATA_RANGE_FLAG_IS_COMPRESSED ) != 0 )
332
0
  {
333
0
    if( ( element_data_size == 0 )
334
0
     || ( element_data_size > (size64_t) SSIZE_MAX ) )
335
0
    {
336
0
      libcerror_error_set(
337
0
       error,
338
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
339
0
       LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
340
0
       "%s: invalid element data size value out of bounds.",
341
0
       function );
342
343
0
      return( -1 );
344
0
    }
345
0
  }
346
0
  if( libfdata_list_element_get_mapped_size(
347
0
       element,
348
0
       &mapped_size,
349
0
       error ) != 1 )
350
0
  {
351
0
    libcerror_error_set(
352
0
     error,
353
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
354
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
355
0
     "%s: unable to retrieve mapped size from element.",
356
0
     function );
357
358
0
    goto on_error;
359
0
  }
360
0
  if( ( mapped_size == 0 )
361
0
   || ( mapped_size > (size64_t) SSIZE_MAX ) )
362
0
  {
363
0
    libcerror_error_set(
364
0
     error,
365
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
366
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
367
0
     "%s: invalid block chunk data size value out of bounds.",
368
0
     function );
369
370
0
    goto on_error;
371
0
  }
372
0
  if( libmodi_data_block_initialize(
373
0
       &data_block,
374
0
       (size_t) mapped_size,
375
0
       error ) != 1 )
376
0
  {
377
0
    libcerror_error_set(
378
0
     error,
379
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
380
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
381
0
     "%s: unable to create data block.",
382
0
     function );
383
384
0
    goto on_error;
385
0
  }
386
0
  if( ( element_data_flags & LIBFDATA_RANGE_FLAG_IS_SPARSE ) != 0 )
387
0
  {
388
0
    if( memory_set(
389
0
         data_block->data,
390
0
         0,
391
0
         data_block->data_size ) == NULL )
392
0
    {
393
0
      libcerror_error_set(
394
0
       error,
395
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
396
0
       LIBCERROR_MEMORY_ERROR_SET_FAILED,
397
0
       "%s: unable to clear data block.",
398
0
       function );
399
400
0
      goto on_error;
401
0
    }
402
0
  }
403
0
  else if( ( element_data_flags & LIBFDATA_RANGE_FLAG_IS_COMPRESSED ) != 0 )
404
0
  {
405
#if defined( HAVE_DEBUG_OUTPUT )
406
    if( libcnotify_verbose != 0 )
407
    {
408
      libcnotify_printf(
409
       "%s: reading compressed block chunk at offset: %" PRIi64 " (0x%08" PRIx64 ")\n",
410
       function,
411
       element_data_offset,
412
       element_data_offset );
413
    }
414
#endif
415
0
    compressed_data = (uint8_t *) memory_allocate(
416
0
                                   sizeof( uint8_t ) * element_data_size );
417
418
0
    if( compressed_data == NULL )
419
0
    {
420
0
      libcerror_error_set(
421
0
       error,
422
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
423
0
       LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
424
0
       "%s: unable to create compressed data.",
425
0
       function );
426
427
0
      goto on_error;
428
0
    }
429
0
    read_count = libbfio_handle_read_buffer_at_offset(
430
0
                  file_io_handle,
431
0
                  compressed_data,
432
0
                  element_data_size,
433
0
                  element_data_offset,
434
0
                  error );
435
436
0
    if( read_count != (ssize_t) element_data_size )
437
0
    {
438
0
      libcerror_error_set(
439
0
       error,
440
0
       LIBCERROR_ERROR_DOMAIN_IO,
441
0
       LIBCERROR_IO_ERROR_READ_FAILED,
442
0
       "%s: unable to read compressed block chunk at offset: %" PRIi64 " (0x%08" PRIx64 ").",
443
0
       function,
444
0
       element_data_offset,
445
0
       element_data_offset );
446
447
0
      goto on_error;
448
0
    }
449
0
    uncompressed_data_size = data_block->data_size;
450
451
0
    if( libmodi_decompress_data(
452
0
         compressed_data,
453
0
         (size_t) read_count,
454
0
         io_handle->compression_method,
455
0
         data_block->data,
456
0
         &uncompressed_data_size,
457
0
         error ) != 1 )
458
0
    {
459
0
      libcerror_error_set(
460
0
       error,
461
0
       LIBCERROR_ERROR_DOMAIN_ENCRYPTION,
462
0
       LIBCERROR_ENCRYPTION_ERROR_GENERIC,
463
0
       "%s: unable to decompress block chunk at offset: %" PRIi64 " (0x%08" PRIx64 ").",
464
0
       function,
465
0
       element_data_offset,
466
0
       element_data_offset );
467
468
0
      goto on_error;
469
0
    }
470
0
    memory_free(
471
0
     compressed_data );
472
473
0
    compressed_data = NULL;
474
0
  }
475
0
  else
476
0
  {
477
0
    if( libmodi_data_block_read_file_io_handle(
478
0
         data_block,
479
0
         file_io_handle,
480
0
         element_data_offset,
481
0
         error ) != 1 )
482
0
    {
483
0
      libcerror_error_set(
484
0
       error,
485
0
       LIBCERROR_ERROR_DOMAIN_IO,
486
0
       LIBCERROR_IO_ERROR_READ_FAILED,
487
0
       "%s: unable to read data block at offset: %" PRIi64 " (0x%08" PRIx64 ").",
488
0
       function,
489
0
       element_data_offset,
490
0
       element_data_offset );
491
492
0
      goto on_error;
493
0
    }
494
0
  }
495
0
  if( libfdata_list_element_set_element_value(
496
0
       element,
497
0
       (intptr_t *) file_io_handle,
498
0
       cache,
499
0
       (intptr_t *) data_block,
500
0
       (int (*)(intptr_t **, libcerror_error_t **)) &libmodi_data_block_free,
501
0
       LIBFDATA_LIST_ELEMENT_VALUE_FLAG_MANAGED,
502
0
       error ) != 1 )
503
0
  {
504
0
    libcerror_error_set(
505
0
     error,
506
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
507
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
508
0
     "%s: unable to set data block as element value.",
509
0
     function );
510
511
0
    goto on_error;
512
0
  }
513
0
  return( 1 );
514
515
0
on_error:
516
0
  if( compressed_data != NULL )
517
0
  {
518
0
    memory_free(
519
0
     compressed_data );
520
0
  }
521
0
  if( data_block != NULL )
522
0
  {
523
0
    libmodi_data_block_free(
524
0
     &data_block,
525
0
     NULL );
526
0
  }
527
0
  return( -1 );
528
0
}
529
530
/* Reads a data block
531
 * Callback function for the data block vector
532
 * Returns 1 if successful or -1 on error
533
 */
534
int libmodi_data_block_read_vector_element_data(
535
     libmodi_io_handle_t *io_handle,
536
     intptr_t *file_io_handle,
537
     libfdata_vector_t *vector,
538
     libfdata_cache_t *cache,
539
     int element_index,
540
     int element_data_file_index,
541
     off64_t element_data_offset,
542
     size64_t element_data_size,
543
     uint32_t element_data_flags,
544
     uint8_t read_flags LIBMODI_ATTRIBUTE_UNUSED,
545
     libcerror_error_t **error )
546
0
{
547
0
  libbfio_handle_t *bfio_handle    = NULL;
548
0
  libmodi_data_block_t *data_block = NULL;
549
0
  static char *function            = "libmodi_data_block_read_vector_element_data";
550
551
0
  LIBMODI_UNREFERENCED_PARAMETER( read_flags );
552
553
0
  if( io_handle == NULL )
554
0
  {
555
0
    libcerror_error_set(
556
0
     error,
557
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
558
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
559
0
     "%s: invalid IO handle.",
560
0
     function );
561
562
0
    return( -1 );
563
0
  }
564
0
  if( ( io_handle->image_type != LIBMODI_IMAGE_TYPE_SPARSE_BUNDLE )
565
0
   && ( element_data_file_index != 0 ) )
566
0
  {
567
0
    libcerror_error_set(
568
0
     error,
569
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
570
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
571
0
     "%s: invalid element data file index value out of bounds.",
572
0
     function );
573
574
0
    return( -1 );
575
0
  }
576
0
  if( ( element_data_size == 0 )
577
0
   || ( element_data_size > (size64_t) SSIZE_MAX ) )
578
0
  {
579
0
    libcerror_error_set(
580
0
     error,
581
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
582
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
583
0
     "%s: invalid element data size value out of bounds.",
584
0
     function );
585
586
0
    return( -1 );
587
0
  }
588
0
  if( libmodi_data_block_initialize(
589
0
       &data_block,
590
0
       (size_t) element_data_size,
591
0
       error ) != 1 )
592
0
  {
593
0
    libcerror_error_set(
594
0
     error,
595
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
596
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
597
0
     "%s: unable to create data block.",
598
0
     function );
599
600
0
    goto on_error;
601
0
  }
602
0
  if( ( element_data_flags & LIBFDATA_RANGE_FLAG_IS_SPARSE ) != 0 )
603
0
  {
604
0
    if( memory_set(
605
0
         data_block->data,
606
0
         0,
607
0
         data_block->data_size ) == NULL )
608
0
    {
609
0
      libcerror_error_set(
610
0
       error,
611
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
612
0
       LIBCERROR_MEMORY_ERROR_SET_FAILED,
613
0
       "%s: unable to clear data block.",
614
0
       function );
615
616
0
      goto on_error;
617
0
    }
618
0
  }
619
0
  else
620
0
  {
621
0
    if( io_handle->image_type != LIBMODI_IMAGE_TYPE_SPARSE_BUNDLE )
622
0
    {
623
0
      bfio_handle = (libbfio_handle_t *) file_io_handle;
624
0
    }
625
0
    else if( libbfio_pool_get_handle(
626
0
              (libbfio_pool_t *) file_io_handle,
627
0
              element_data_file_index,
628
0
              &bfio_handle,
629
0
              error ) != 1 )
630
0
    {
631
0
      libcerror_error_set(
632
0
       error,
633
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
634
0
       LIBCERROR_RUNTIME_ERROR_GET_FAILED,
635
0
       "%s: unable to retrieve handle: %d from file IO pool.",
636
0
       function,
637
0
       element_data_file_index );
638
639
0
      goto on_error;
640
0
    }
641
0
    if( libmodi_data_block_read_file_io_handle(
642
0
         data_block,
643
0
         bfio_handle,
644
0
         element_data_offset,
645
0
         error ) != 1 )
646
0
    {
647
0
      libcerror_error_set(
648
0
       error,
649
0
       LIBCERROR_ERROR_DOMAIN_IO,
650
0
       LIBCERROR_IO_ERROR_READ_FAILED,
651
0
       "%s: unable to read data block at offset: %" PRIi64 " (0x%08" PRIx64 ").",
652
0
       function,
653
0
       element_data_offset,
654
0
       element_data_offset );
655
656
0
      goto on_error;
657
0
    }
658
0
  }
659
0
  if( libfdata_vector_set_element_value_by_index(
660
0
       vector,
661
0
       (intptr_t *) file_io_handle,
662
0
       cache,
663
0
       element_index,
664
0
       (intptr_t *) data_block,
665
0
       (int (*)(intptr_t **, libcerror_error_t **)) &libmodi_data_block_free,
666
0
       LIBFDATA_LIST_ELEMENT_VALUE_FLAG_MANAGED,
667
0
       error ) != 1 )
668
0
  {
669
0
    libcerror_error_set(
670
0
     error,
671
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
672
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
673
0
     "%s: unable to set data block as element value.",
674
0
     function );
675
676
0
    goto on_error;
677
0
  }
678
0
  return( 1 );
679
680
0
on_error:
681
0
  if( data_block != NULL )
682
0
  {
683
0
    libmodi_data_block_free(
684
0
     &data_block,
685
0
     NULL );
686
0
  }
687
0
  return( -1 );
688
0
}
689