Coverage Report

Created: 2026-03-05 07:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libesedb/libesedb/libesedb_long_value.c
Line
Count
Source
1
/*
2
 * Long value functions
3
 *
4
 * Copyright (C) 2009-2025, 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 "libesedb_compression.h"
28
#include "libesedb_data_segment.h"
29
#include "libesedb_definitions.h"
30
#include "libesedb_libbfio.h"
31
#include "libesedb_libcerror.h"
32
#include "libesedb_libcnotify.h"
33
#include "libesedb_libfcache.h"
34
#include "libesedb_libfdata.h"
35
#include "libesedb_libfvalue.h"
36
#include "libesedb_long_value.h"
37
#include "libesedb_record_value.h"
38
39
/* Creates a long value
40
 * Make sure the value long_value is referencing, is set to NULL
41
 * Returns 1 if successful or -1 on error
42
 */
43
int libesedb_long_value_initialize(
44
     libesedb_long_value_t **long_value,
45
     libbfio_handle_t *file_io_handle,
46
     libesedb_io_handle_t *io_handle,
47
     libesedb_catalog_definition_t *column_catalog_definition,
48
     libfdata_list_t *data_segments_list,
49
     libcerror_error_t **error )
50
0
{
51
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
52
0
  static char *function                               = "libesedb_long_value_initialize";
53
54
0
  if( long_value == NULL )
55
0
  {
56
0
    libcerror_error_set(
57
0
     error,
58
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
59
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
60
0
     "%s: invalid long value.",
61
0
     function );
62
63
0
    return( -1 );
64
0
  }
65
0
  if( *long_value != NULL )
66
0
  {
67
0
    libcerror_error_set(
68
0
     error,
69
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
70
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
71
0
     "%s: invalid long value value already set.",
72
0
     function );
73
74
0
    return( -1 );
75
0
  }
76
0
  if( column_catalog_definition == NULL )
77
0
  {
78
0
    libcerror_error_set(
79
0
     error,
80
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
81
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
82
0
     "%s: invalid column catalog definition.",
83
0
     function );
84
85
0
    return( -1 );
86
0
  }
87
0
  if( data_segments_list == NULL )
88
0
  {
89
0
    libcerror_error_set(
90
0
     error,
91
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
92
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
93
0
     "%s: invalid data segments list.",
94
0
     function );
95
96
0
    return( -1 );
97
0
  }
98
0
  internal_long_value = memory_allocate_structure(
99
0
                         libesedb_internal_long_value_t );
100
101
0
  if( internal_long_value == NULL )
102
0
  {
103
0
    libcerror_error_set(
104
0
     error,
105
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
106
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
107
0
     "%s: unable to create long value.",
108
0
     function );
109
110
0
    goto on_error;
111
0
  }
112
0
  if( memory_set(
113
0
       internal_long_value,
114
0
       0,
115
0
       sizeof( libesedb_internal_long_value_t ) ) == NULL )
116
0
  {
117
0
    libcerror_error_set(
118
0
     error,
119
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
120
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
121
0
     "%s: unable to clear long value.",
122
0
     function );
123
124
0
    memory_free(
125
0
     internal_long_value );
126
127
0
    return( -1 );
128
0
  }
129
0
  if( libfcache_cache_initialize(
130
0
       &( internal_long_value->data_segments_cache ),
131
0
       LIBESEDB_MAXIMUM_CACHE_ENTRIES_LONG_VALUES_DATA,
132
0
       error ) != 1 )
133
0
  {
134
0
    libcerror_error_set(
135
0
     error,
136
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
137
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
138
0
     "%s: unable to create data segments cache.",
139
0
     function );
140
141
0
    goto on_error;
142
0
  }
143
0
  internal_long_value->file_io_handle            = file_io_handle;
144
0
  internal_long_value->io_handle                 = io_handle;
145
0
  internal_long_value->column_catalog_definition = column_catalog_definition;
146
0
  internal_long_value->data_segments_list        = data_segments_list;
147
148
0
  *long_value = (libesedb_long_value_t *) internal_long_value;
149
150
0
  return( 1 );
151
152
0
on_error:
153
0
  if( internal_long_value != NULL )
154
0
  {
155
0
    if( internal_long_value->data_segments_cache != NULL )
156
0
    {
157
0
      libfcache_cache_free(
158
0
       &( internal_long_value->data_segments_cache ),
159
0
       NULL );
160
0
    }
161
0
    memory_free(
162
0
     internal_long_value );
163
0
  }
164
0
  return( -1 );
165
0
}
166
167
/* Frees a long value
168
 * Returns 1 if successful or -1 on error
169
 */
170
int libesedb_long_value_free(
171
     libesedb_long_value_t **long_value,
172
     libcerror_error_t **error )
173
0
{
174
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
175
0
  static char *function                               = "libesedb_long_value_free";
176
0
  int result                                          = 1;
177
178
0
  if( long_value == NULL )
179
0
  {
180
0
    libcerror_error_set(
181
0
     error,
182
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
183
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
184
0
     "%s: invalid long value.",
185
0
     function );
186
187
0
    return( -1 );
188
0
  }
189
0
  if( *long_value != NULL )
190
0
  {
191
0
    internal_long_value = (libesedb_internal_long_value_t *) *long_value;
192
0
    *long_value         = NULL;
193
194
    /* The file_io_handle and io_handle references are freed elsewhere
195
     */
196
0
    if( libfdata_list_free(
197
0
         &( internal_long_value->data_segments_list ),
198
0
         error ) != 1 )
199
0
    {
200
0
      libcerror_error_set(
201
0
       error,
202
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
203
0
       LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
204
0
       "%s: unable to free data segments list.",
205
0
       function );
206
207
0
      result = -1;
208
0
    }
209
0
    if( libfcache_cache_free(
210
0
         &( internal_long_value->data_segments_cache ),
211
0
         error ) != 1 )
212
0
    {
213
0
      libcerror_error_set(
214
0
       error,
215
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
216
0
       LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
217
0
       "%s: unable to free data segments cache.",
218
0
       function );
219
220
0
      result = -1;
221
0
    }
222
0
    if( internal_long_value->record_value != NULL )
223
0
    {
224
0
      if( libfvalue_value_free(
225
0
           &( internal_long_value->record_value ),
226
0
           error ) != 1 )
227
0
      {
228
0
        libcerror_error_set(
229
0
         error,
230
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
231
0
         LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
232
0
         "%s: unable to free record value.",
233
0
         function );
234
235
0
        result = -1;
236
0
      }
237
0
    }
238
0
    memory_free(
239
0
     internal_long_value );
240
0
  }
241
0
  return( result );
242
0
}
243
244
/* Retrieve the data size
245
 * Returns 1 if successful or -1 on error
246
 */
247
int libesedb_long_value_get_data_size(
248
     libesedb_long_value_t *long_value,
249
     size64_t *data_size,
250
     libcerror_error_t **error )
251
0
{
252
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
253
0
  static char *function                               = "libesedb_long_value_get_data_size";
254
255
0
  if( long_value == NULL )
256
0
  {
257
0
    libcerror_error_set(
258
0
     error,
259
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
260
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
261
0
     "%s: invalid long value.",
262
0
     function );
263
264
0
    return( -1 );
265
0
  }
266
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
267
268
0
  if( libfdata_list_get_size(
269
0
       internal_long_value->data_segments_list,
270
0
       data_size,
271
0
       error ) != 1 )
272
0
  {
273
0
    libcerror_error_set(
274
0
     error,
275
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
276
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
277
0
     "%s: unable to retrieve size from data segments list.",
278
0
     function );
279
280
0
    return( -1 );
281
0
  }
282
0
  return( 1 );
283
0
}
284
285
/* Retrieve the data
286
 * Returns 1 if successful or -1 on error
287
 */
288
int libesedb_long_value_get_data(
289
     libesedb_long_value_t *long_value,
290
     uint8_t *data,
291
     size_t data_size,
292
     libcerror_error_t **error )
293
0
{
294
0
  libesedb_data_segment_t *data_segment               = NULL;
295
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
296
0
  static char *function                               = "libesedb_long_value_get_data";
297
0
  size64_t data_segments_size                         = 0;
298
0
  size_t data_offset                                  = 0;
299
0
  int data_segment_index                              = 0;
300
0
  int number_of_data_segments                         = 0;
301
302
0
  if( long_value == NULL )
303
0
  {
304
0
    libcerror_error_set(
305
0
     error,
306
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
307
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
308
0
     "%s: invalid long value.",
309
0
     function );
310
311
0
    return( -1 );
312
0
  }
313
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
314
315
0
  if( data == NULL )
316
0
  {
317
0
    libcerror_error_set(
318
0
     error,
319
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
320
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
321
0
     "%s: invalid data.",
322
0
     function );
323
324
0
    return( -1 );
325
0
  }
326
0
  if( data_size > (size_t) SSIZE_MAX )
327
0
  {
328
0
    libcerror_error_set(
329
0
     error,
330
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
331
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
332
0
     "%s: invalid data size value exceeds maximum.",
333
0
     function );
334
335
0
    return( -1 );
336
0
  }
337
0
  if( libfdata_list_get_size(
338
0
       internal_long_value->data_segments_list,
339
0
       &data_segments_size,
340
0
       error ) != 1 )
341
0
  {
342
0
    libcerror_error_set(
343
0
     error,
344
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
345
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
346
0
     "%s: unable to retrieve size from data segments list.",
347
0
     function );
348
349
0
    return( -1 );
350
0
  }
351
0
  if( (size64_t) data_size < data_segments_size )
352
0
  {
353
0
    libcerror_error_set(
354
0
     error,
355
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
356
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
357
0
     "%s: data size value too small.",
358
0
     function );
359
360
0
    return( -1 );
361
0
  }
362
0
  if( libfdata_list_get_number_of_elements(
363
0
       internal_long_value->data_segments_list,
364
0
       &number_of_data_segments,
365
0
       error ) != 1 )
366
0
  {
367
0
    libcerror_error_set(
368
0
     error,
369
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
370
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
371
0
     "%s: unable to retrieve number of elements from data segments list.",
372
0
     function );
373
374
0
    return( -1 );
375
0
  }
376
0
  for( data_segment_index = 0;
377
0
       data_segment_index < number_of_data_segments;
378
0
       data_segment_index++ )
379
0
  {
380
0
    if( libfdata_list_get_element_value_by_index(
381
0
         internal_long_value->data_segments_list,
382
0
         (intptr_t *) internal_long_value->file_io_handle,
383
0
         (libfdata_cache_t *) internal_long_value->data_segments_cache,
384
0
         data_segment_index,
385
0
         (intptr_t **) &data_segment,
386
0
         0,
387
0
         error ) != 1 )
388
0
    {
389
0
      libcerror_error_set(
390
0
       error,
391
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
392
0
       LIBCERROR_RUNTIME_ERROR_GET_FAILED,
393
0
       "%s: unable to retrieve data segment: %d.",
394
0
       function,
395
0
       data_segment_index );
396
397
0
      return( -1 );
398
0
    }
399
0
    if( data_segment == NULL )
400
0
    {
401
0
      libcerror_error_set(
402
0
       error,
403
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
404
0
       LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
405
0
       "%s: missing data segment: %d.",
406
0
       function,
407
0
       data_segment_index );
408
409
0
      return( -1 );
410
0
    }
411
0
    if( memory_copy(
412
0
         &( data[ data_offset ] ),
413
0
         data_segment->data,
414
0
         data_segment->data_size ) == NULL )
415
0
    {
416
0
      libcerror_error_set(
417
0
       error,
418
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
419
0
       LIBCERROR_MEMORY_ERROR_COPY_FAILED,
420
0
       "%s: unable to copy data.",
421
0
       function );
422
423
0
      return( -1 );
424
0
    }
425
0
    data_offset += data_segment->data_size;
426
0
  }
427
0
  return( 1 );
428
0
}
429
430
/* Retrieve the record value
431
 * Returns 1 if successful or -1 on error
432
 */
433
int libesedb_long_value_get_record_value(
434
     libesedb_internal_long_value_t *internal_long_value,
435
     libfvalue_value_t **record_value,
436
     libcerror_error_t **error )
437
0
{
438
0
  libesedb_data_segment_t *data_segment = NULL;
439
0
  uint8_t *compressed_data              = NULL;
440
0
  uint8_t *data                         = NULL;
441
0
  static char *function                 = "libesedb_long_value_get_record_value";
442
0
  size64_t data_size                    = 0;
443
0
  size_t compressed_data_size           = 0;
444
0
  size_t data_offset                    = 0;
445
0
  uint32_t column_type                  = 0;
446
0
  uint8_t record_value_type             = 0;
447
0
  int data_segment_index                = 0;
448
0
  int encoding                          = 0;
449
0
  int long_value_codepage               = 0;
450
0
  int number_of_data_segments           = 0;
451
452
0
  if( internal_long_value == NULL )
453
0
  {
454
0
    libcerror_error_set(
455
0
     error,
456
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
457
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
458
0
     "%s: invalid long value.",
459
0
     function );
460
461
0
    return( -1 );
462
0
  }
463
0
  if( internal_long_value->io_handle == NULL )
464
0
  {
465
0
    libcerror_error_set(
466
0
     error,
467
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
468
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
469
0
     "%s: invalid long value - missing IO handle.",
470
0
     function );
471
472
0
    return( -1 );
473
0
  }
474
0
  if( record_value == NULL )
475
0
  {
476
0
    libcerror_error_set(
477
0
     error,
478
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
479
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
480
0
     "%s: invalid record value.",
481
0
     function );
482
483
0
    return( -1 );
484
0
  }
485
0
  if( internal_long_value->record_value == NULL )
486
0
  {
487
0
    if( libfdata_list_get_size(
488
0
         internal_long_value->data_segments_list,
489
0
         &data_size,
490
0
         error ) != 1 )
491
0
    {
492
0
      libcerror_error_set(
493
0
       error,
494
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
495
0
       LIBCERROR_RUNTIME_ERROR_GET_FAILED,
496
0
       "%s: unable to retrieve size from data segments list.",
497
0
       function );
498
499
0
      goto on_error;
500
0
    }
501
0
    if( ( data_size == 0 )
502
0
     || ( data_size > (size64_t) MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
503
0
    {
504
0
      libcerror_error_set(
505
0
       error,
506
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
507
0
       LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
508
0
       "%s: invalid data size value out of bounds.",
509
0
       function );
510
511
0
      goto on_error;
512
0
    }
513
0
    data = (uint8_t *) memory_allocate(
514
0
                        (size_t) data_size );
515
516
0
    if( data == NULL )
517
0
    {
518
0
      libcerror_error_set(
519
0
       error,
520
0
       LIBCERROR_ERROR_DOMAIN_MEMORY,
521
0
       LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
522
0
       "%s: unable to create data.",
523
0
       function );
524
525
0
      goto on_error;
526
0
    }
527
0
    if( libfdata_list_get_number_of_elements(
528
0
         internal_long_value->data_segments_list,
529
0
         &number_of_data_segments,
530
0
         error ) != 1 )
531
0
    {
532
0
      libcerror_error_set(
533
0
       error,
534
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
535
0
       LIBCERROR_RUNTIME_ERROR_GET_FAILED,
536
0
       "%s: unable to retrieve number of elements from data segments list.",
537
0
       function );
538
539
0
      goto on_error;
540
0
    }
541
0
    for( data_segment_index = 0;
542
0
         data_segment_index < number_of_data_segments;
543
0
         data_segment_index++ )
544
0
    {
545
0
      if( libfdata_list_get_element_value_by_index(
546
0
           internal_long_value->data_segments_list,
547
0
           (intptr_t *) internal_long_value->file_io_handle,
548
0
           (libfdata_cache_t *) internal_long_value->data_segments_cache,
549
0
           data_segment_index,
550
0
           (intptr_t **) &data_segment,
551
0
           0,
552
0
           error ) != 1 )
553
0
      {
554
0
        libcerror_error_set(
555
0
         error,
556
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
557
0
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
558
0
         "%s: unable to retrieve data segment: %d.",
559
0
         function,
560
0
         data_segment_index );
561
562
0
        goto on_error;
563
0
      }
564
0
      if( data_segment == NULL )
565
0
      {
566
0
        libcerror_error_set(
567
0
         error,
568
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
569
0
         LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
570
0
         "%s: missing data segment: %d.",
571
0
         function,
572
0
         data_segment_index );
573
574
0
        goto on_error;
575
0
      }
576
0
      if( memory_copy(
577
0
           &( data[ data_offset ] ),
578
0
           data_segment->data,
579
0
           data_segment->data_size ) == NULL )
580
0
      {
581
0
        libcerror_error_set(
582
0
         error,
583
0
         LIBCERROR_ERROR_DOMAIN_MEMORY,
584
0
         LIBCERROR_MEMORY_ERROR_COPY_FAILED,
585
0
         "%s: unable to copy data.",
586
0
         function );
587
588
0
        goto on_error;
589
0
      }
590
0
      data_offset += data_segment->data_size;
591
0
    }
592
0
    if( libesedb_catalog_definition_get_column_type(
593
0
         internal_long_value->column_catalog_definition,
594
0
         &column_type,
595
0
         error ) != 1 )
596
0
    {
597
0
      libcerror_error_set(
598
0
       error,
599
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
600
0
       LIBCERROR_RUNTIME_ERROR_GET_FAILED,
601
0
       "%s: unable to retrieve catalog definition column type.",
602
0
       function );
603
604
0
      goto on_error;
605
0
    }
606
0
    switch( column_type )
607
0
    {
608
0
      case LIBESEDB_COLUMN_TYPE_BINARY_DATA:
609
0
      case LIBESEDB_COLUMN_TYPE_LARGE_BINARY_DATA:
610
0
        record_value_type = LIBFVALUE_VALUE_TYPE_BINARY_DATA;
611
0
        break;
612
613
0
      case LIBESEDB_COLUMN_TYPE_TEXT:
614
0
      case LIBESEDB_COLUMN_TYPE_LARGE_TEXT:
615
0
        record_value_type = LIBFVALUE_VALUE_TYPE_STRING_BYTE_STREAM;
616
0
        break;
617
618
0
      default:
619
0
        libcerror_error_set(
620
0
         error,
621
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
622
0
         LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
623
0
         "%s: unsupported column type: %" PRIu32 ".",
624
0
         function,
625
0
         column_type );
626
627
0
        goto on_error;
628
0
    }
629
0
    if( ( column_type == LIBESEDB_COLUMN_TYPE_TEXT )
630
0
     || ( column_type == LIBESEDB_COLUMN_TYPE_LARGE_TEXT ) )
631
0
    {
632
0
      long_value_codepage = (int) internal_long_value->column_catalog_definition->codepage;
633
634
      /* If the codepage is not set use the default codepage
635
       */
636
0
      if( long_value_codepage == 0 )
637
0
      {
638
0
        long_value_codepage = internal_long_value->io_handle->ascii_codepage;
639
0
      }
640
0
      if( ( data_size > 1 )
641
0
       && ( data[ 0 ] == 0x18 ) )
642
0
      {
643
0
        compressed_data      = data;
644
0
        compressed_data_size = data_size;
645
0
        data                 = NULL;
646
0
        data_size            = 0;
647
648
0
        if( libesedb_compression_lzxpress_decompress_get_size(
649
0
             compressed_data,
650
0
             compressed_data_size,
651
0
             (size_t *) &data_size,
652
0
             error ) != 1 )
653
0
        {
654
0
          libcerror_error_set(
655
0
           error,
656
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
657
0
           LIBCERROR_RUNTIME_ERROR_GET_FAILED,
658
0
           "%s: unable retrieve uncompressed data size.",
659
0
           function );
660
661
0
          goto on_error;
662
0
        }
663
0
        if( ( data_size == 0 )
664
0
         || ( data_size > MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
665
0
        {
666
0
          libcerror_error_set(
667
0
           error,
668
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
669
0
           LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
670
0
           "%s: invalid uncompressed data size value out of bounds.",
671
0
           function );
672
673
0
          goto on_error;
674
0
        }
675
0
        data = (uint8_t *) memory_allocate(
676
0
                            sizeof( uint8_t ) * data_size );
677
678
0
        if( data == NULL )
679
0
        {
680
0
          libcerror_error_set(
681
0
           error,
682
0
           LIBCERROR_ERROR_DOMAIN_MEMORY,
683
0
           LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
684
0
           "%s: unable to create uncompressed data.",
685
0
           function );
686
687
0
          goto on_error;
688
0
        }
689
0
        if( libesedb_compression_lzxpress_decompress(
690
0
             compressed_data,
691
0
             compressed_data_size,
692
0
             data,
693
0
             data_size,
694
0
             error ) != 1 )
695
0
        {
696
0
          libcerror_error_set(
697
0
           error,
698
0
           LIBCERROR_ERROR_DOMAIN_COMPRESSION,
699
0
           LIBCERROR_COMPRESSION_ERROR_DECOMPRESS_FAILED,
700
0
           "%s: unable decompressed data.",
701
0
           function );
702
703
0
          goto on_error;
704
0
        }
705
0
        memory_free(
706
0
         compressed_data );
707
708
0
        compressed_data = NULL;
709
710
#if defined( HAVE_DEBUG_OUTPUT )
711
        if( libcnotify_verbose != 0 )
712
        {
713
          libcnotify_printf(
714
           "%s: uncompressed data:\n",
715
           function );
716
          libcnotify_print_data(
717
           data,
718
           data_size,
719
           0 );
720
        }
721
#endif
722
0
      }
723
0
      encoding = long_value_codepage;
724
0
    }
725
0
    else
726
0
    {
727
0
      encoding = LIBFVALUE_ENDIAN_LITTLE;
728
0
    }
729
/* TODO create value */
730
0
    if( libfvalue_value_type_initialize(
731
0
         &( internal_long_value->record_value ),
732
0
         record_value_type,
733
0
         error ) != 1 )
734
0
    {
735
0
      libcerror_error_set(
736
0
       error,
737
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
738
0
       LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
739
0
       "%s: unable to create record value.",
740
0
       function );
741
742
0
      goto on_error;
743
0
    }
744
0
    if( libfvalue_value_set_data(
745
0
         internal_long_value->record_value,
746
0
         data,
747
0
         (size_t) data_size,
748
0
         encoding,
749
0
         LIBFVALUE_VALUE_DATA_FLAG_MANAGED | LIBFVALUE_VALUE_DATA_FLAG_CLONE_BY_REFERENCE,
750
0
         error ) != 1 )
751
0
    {
752
0
      libcerror_error_set(
753
0
       error,
754
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
755
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
756
0
       "%s: unable to set data in record value.",
757
0
       function );
758
759
0
      goto on_error;
760
0
    }
761
    /* The record value takes over management of data
762
     */
763
0
    data = NULL;
764
0
  }
765
0
  *record_value = internal_long_value->record_value;
766
767
0
  return( 1 );
768
769
0
on_error:
770
0
  if( internal_long_value->record_value != NULL )
771
0
  {
772
0
    libfvalue_value_free(
773
0
     &( internal_long_value->record_value ),
774
0
     NULL );
775
0
  }
776
0
  if( compressed_data != NULL )
777
0
  {
778
0
    memory_free(
779
0
     compressed_data );
780
0
  }
781
0
  if( data != NULL )
782
0
  {
783
0
    memory_free(
784
0
     data );
785
0
  }
786
0
  return( -1 );
787
0
}
788
789
/* Retrieve the number of data segments
790
 * Returns 1 if successful or -1 on error
791
 */
792
int libesedb_long_value_get_number_of_data_segments(
793
     libesedb_long_value_t *long_value,
794
     int *number_of_data_segments,
795
     libcerror_error_t **error )
796
0
{
797
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
798
0
  static char *function                               = "libesedb_long_value_get_number_of_data_segments";
799
800
0
  if( long_value == NULL )
801
0
  {
802
0
    libcerror_error_set(
803
0
     error,
804
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
805
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
806
0
     "%s: invalid long value.",
807
0
     function );
808
809
0
    return( -1 );
810
0
  }
811
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
812
813
0
  if( libfdata_list_get_number_of_elements(
814
0
       internal_long_value->data_segments_list,
815
0
       number_of_data_segments,
816
0
       error ) != 1 )
817
0
  {
818
0
    libcerror_error_set(
819
0
     error,
820
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
821
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
822
0
     "%s: unable to retrieve number of elements from data segments list.",
823
0
     function );
824
825
0
    return( -1 );
826
0
  }
827
0
  return( 1 );
828
0
}
829
830
/* Retrieve the data segment size
831
 * Returns 1 if successful or -1 on error
832
 */
833
int libesedb_long_value_get_data_segment_size(
834
     libesedb_long_value_t *long_value,
835
     int data_segment_index,
836
     size_t *data_size,
837
     libcerror_error_t **error )
838
0
{
839
0
  libesedb_data_segment_t *data_segment               = NULL;
840
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
841
0
  static char *function                               = "libesedb_long_value_get_data_segment_size";
842
843
0
  if( long_value == NULL )
844
0
  {
845
0
    libcerror_error_set(
846
0
     error,
847
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
848
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
849
0
     "%s: invalid long value.",
850
0
     function );
851
852
0
    return( -1 );
853
0
  }
854
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
855
856
0
  if( libfdata_list_get_element_value_by_index(
857
0
       internal_long_value->data_segments_list,
858
0
       (intptr_t *) internal_long_value->file_io_handle,
859
0
       (libfdata_cache_t *) internal_long_value->data_segments_cache,
860
0
       data_segment_index,
861
0
       (intptr_t **) &data_segment,
862
0
       0,
863
0
       error ) != 1 )
864
0
  {
865
0
    libcerror_error_set(
866
0
     error,
867
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
868
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
869
0
     "%s: unable to retrieve data segment: %d.",
870
0
     function,
871
0
     data_segment_index );
872
873
0
    return( -1 );
874
0
  }
875
0
  if( libesedb_data_segment_get_data_size(
876
0
       data_segment,
877
0
       data_size,
878
0
       error ) != 1 )
879
0
  {
880
0
    libcerror_error_set(
881
0
     error,
882
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
883
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
884
0
     "%s: unable to retrieve data segment: %d data size.",
885
0
     function,
886
0
     data_segment_index );
887
888
0
    return( -1 );
889
0
  }
890
0
  return( 1 );
891
0
}
892
893
/* Retrieve the data segment
894
 * Returns 1 if successful or -1 on error
895
 */
896
int libesedb_long_value_get_data_segment(
897
     libesedb_long_value_t *long_value,
898
     int data_segment_index,
899
     uint8_t *data,
900
     size_t data_size,
901
     libcerror_error_t **error )
902
0
{
903
0
  libesedb_data_segment_t *data_segment               = NULL;
904
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
905
0
  static char *function                               = "libesedb_long_value_get_data_segment";
906
907
0
  if( long_value == NULL )
908
0
  {
909
0
    libcerror_error_set(
910
0
     error,
911
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
912
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
913
0
     "%s: invalid long value.",
914
0
     function );
915
916
0
    return( -1 );
917
0
  }
918
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
919
920
0
  if( libfdata_list_get_element_value_by_index(
921
0
       internal_long_value->data_segments_list,
922
0
       (intptr_t *) internal_long_value->file_io_handle,
923
0
       (libfdata_cache_t *) internal_long_value->data_segments_cache,
924
0
       data_segment_index,
925
0
       (intptr_t **) &data_segment,
926
0
       0,
927
0
       error ) != 1 )
928
0
  {
929
0
    libcerror_error_set(
930
0
     error,
931
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
932
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
933
0
     "%s: unable to retrieve data segment: %d.",
934
0
     function,
935
0
     data_segment_index );
936
937
0
    return( -1 );
938
0
  }
939
0
  if( libesedb_data_segment_get_data(
940
0
       data_segment,
941
0
       data,
942
0
       data_size,
943
0
       error ) != 1 )
944
0
  {
945
0
    libcerror_error_set(
946
0
     error,
947
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
948
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
949
0
     "%s: unable to retrieve data segment: %d data.",
950
0
     function,
951
0
     data_segment_index );
952
953
0
    return( -1 );
954
0
  }
955
0
  return( 1 );
956
0
}
957
958
/* Retrieves the size of the data as an UTF-8 encoded string
959
 * The returned size includes the end of string character
960
 * Returns 1 if successful, 0 if value is NULL or -1 on error
961
 */
962
int libesedb_long_value_get_utf8_string_size(
963
     libesedb_long_value_t *long_value,
964
     size_t *utf8_string_size,
965
     libcerror_error_t **error )
966
0
{
967
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
968
0
  libfvalue_value_t *record_value                     = NULL;
969
0
  static char *function                               = "libesedb_long_value_get_utf8_string_size";
970
0
  uint32_t column_type                                = 0;
971
0
  int result                                          = 0;
972
973
0
  if( long_value == NULL )
974
0
  {
975
0
    libcerror_error_set(
976
0
     error,
977
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
978
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
979
0
     "%s: invalid long value.",
980
0
     function );
981
982
0
    return( -1 );
983
0
  }
984
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
985
986
0
  if( libesedb_catalog_definition_get_column_type(
987
0
       internal_long_value->column_catalog_definition,
988
0
       &column_type,
989
0
       error ) != 1 )
990
0
  {
991
0
    libcerror_error_set(
992
0
     error,
993
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
994
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
995
0
     "%s: unable to retrieve catalog definition column type.",
996
0
     function );
997
998
0
    return( -1 );
999
0
  }
1000
0
  if( ( column_type != LIBESEDB_COLUMN_TYPE_TEXT )
1001
0
   && ( column_type != LIBESEDB_COLUMN_TYPE_LARGE_TEXT ) )
1002
0
  {
1003
0
    libcerror_error_set(
1004
0
     error,
1005
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1006
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
1007
0
     "%s: unsupported column type: %" PRIu32 ".",
1008
0
     function,
1009
0
     column_type );
1010
1011
0
    return( -1 );
1012
0
  }
1013
0
  if( libesedb_long_value_get_record_value(
1014
0
       internal_long_value,
1015
0
       &record_value,
1016
0
       error ) != 1 )
1017
0
  {
1018
0
    libcerror_error_set(
1019
0
     error,
1020
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1021
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1022
0
     "%s: unable to retrieve record value.",
1023
0
     function );
1024
1025
0
    return( -1 );
1026
0
  }
1027
0
  result = libesedb_record_value_get_utf8_string_size(
1028
0
            record_value,
1029
0
            utf8_string_size,
1030
0
            error );
1031
1032
0
  if( result == -1 )
1033
0
  {
1034
0
    libcerror_error_set(
1035
0
     error,
1036
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1037
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1038
0
     "%s: unable to retrieve UTF-8 string size from record value.",
1039
0
     function );
1040
1041
0
    return( -1 );
1042
0
  }
1043
0
  return( result );
1044
0
}
1045
1046
/* Retrieves the data as an UTF-8 encoded string
1047
 * The function uses the codepage in the column definition if necessary
1048
 * The size should include the end of string character
1049
 * Returns 1 if successful, 0 if value is NULL or -1 on error
1050
 */
1051
int libesedb_long_value_get_utf8_string(
1052
     libesedb_long_value_t *long_value,
1053
     uint8_t *utf8_string,
1054
     size_t utf8_string_size,
1055
     libcerror_error_t **error )
1056
0
{
1057
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
1058
0
  libfvalue_value_t *record_value                     = NULL;
1059
0
  static char *function                               = "libesedb_long_value_get_utf8_string";
1060
0
  uint32_t column_type                                = 0;
1061
0
  int result                                          = 0;
1062
1063
0
  if( long_value == NULL )
1064
0
  {
1065
0
    libcerror_error_set(
1066
0
     error,
1067
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1068
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1069
0
     "%s: invalid long value.",
1070
0
     function );
1071
1072
0
    return( -1 );
1073
0
  }
1074
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
1075
1076
0
  if( libesedb_catalog_definition_get_column_type(
1077
0
       internal_long_value->column_catalog_definition,
1078
0
       &column_type,
1079
0
       error ) != 1 )
1080
0
  {
1081
0
    libcerror_error_set(
1082
0
     error,
1083
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1084
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1085
0
     "%s: unable to retrieve catalog definition column type.",
1086
0
     function );
1087
1088
0
    return( -1 );
1089
0
  }
1090
0
  if( ( column_type != LIBESEDB_COLUMN_TYPE_TEXT )
1091
0
   && ( column_type != LIBESEDB_COLUMN_TYPE_LARGE_TEXT ) )
1092
0
  {
1093
0
    libcerror_error_set(
1094
0
     error,
1095
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1096
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
1097
0
     "%s: unsupported column type: %" PRIu32 ".",
1098
0
     function,
1099
0
     column_type );
1100
1101
0
    return( -1 );
1102
0
  }
1103
0
  if( libesedb_long_value_get_record_value(
1104
0
       internal_long_value,
1105
0
       &record_value,
1106
0
       error ) != 1 )
1107
0
  {
1108
0
    libcerror_error_set(
1109
0
     error,
1110
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1111
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1112
0
     "%s: unable to retrieve record value.",
1113
0
     function );
1114
1115
0
    return( -1 );
1116
0
  }
1117
0
  result = libesedb_record_value_get_utf8_string(
1118
0
            record_value,
1119
0
            utf8_string,
1120
0
            utf8_string_size,
1121
0
            error );
1122
1123
0
  if( result == -1 )
1124
0
  {
1125
0
    libcerror_error_set(
1126
0
     error,
1127
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1128
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1129
0
     "%s: unable to retrieve UTF-8 string from record value.",
1130
0
     function );
1131
1132
0
    return( -1 );
1133
0
  }
1134
0
  return( result );
1135
0
}
1136
1137
/* Retrieves the size of the data as an UTF-16 encoded string
1138
 * The returned size includes the end of string character
1139
 * Returns 1 if successful, 0 if value is NULL or -1 on error
1140
 */
1141
int libesedb_long_value_get_utf16_string_size(
1142
     libesedb_long_value_t *long_value,
1143
     size_t *utf16_string_size,
1144
     libcerror_error_t **error )
1145
0
{
1146
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
1147
0
  libfvalue_value_t *record_value                     = NULL;
1148
0
  static char *function                               = "libesedb_long_value_get_utf16_string_size";
1149
0
  uint32_t column_type                                = 0;
1150
0
  int result                                          = 0;
1151
1152
0
  if( long_value == NULL )
1153
0
  {
1154
0
    libcerror_error_set(
1155
0
     error,
1156
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1157
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1158
0
     "%s: invalid long value.",
1159
0
     function );
1160
1161
0
    return( -1 );
1162
0
  }
1163
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
1164
1165
0
  if( libesedb_catalog_definition_get_column_type(
1166
0
       internal_long_value->column_catalog_definition,
1167
0
       &column_type,
1168
0
       error ) != 1 )
1169
0
  {
1170
0
    libcerror_error_set(
1171
0
     error,
1172
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1173
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1174
0
     "%s: unable to retrieve catalog definition column type.",
1175
0
     function );
1176
1177
0
    return( -1 );
1178
0
  }
1179
0
  if( ( column_type != LIBESEDB_COLUMN_TYPE_TEXT )
1180
0
   && ( column_type != LIBESEDB_COLUMN_TYPE_LARGE_TEXT ) )
1181
0
  {
1182
0
    libcerror_error_set(
1183
0
     error,
1184
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1185
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
1186
0
     "%s: unsupported column type: %" PRIu32 ".",
1187
0
     function,
1188
0
     column_type );
1189
1190
0
    return( -1 );
1191
0
  }
1192
0
  if( libesedb_long_value_get_record_value(
1193
0
       internal_long_value,
1194
0
       &record_value,
1195
0
       error ) != 1 )
1196
0
  {
1197
0
    libcerror_error_set(
1198
0
     error,
1199
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1200
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1201
0
     "%s: unable to retrieve record value.",
1202
0
     function );
1203
1204
0
    return( -1 );
1205
0
  }
1206
0
  result = libesedb_record_value_get_utf16_string_size(
1207
0
            record_value,
1208
0
            utf16_string_size,
1209
0
            error );
1210
1211
0
  if( result == -1 )
1212
0
  {
1213
0
    libcerror_error_set(
1214
0
     error,
1215
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1216
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1217
0
     "%s: unable to retrieve UTF-16 string size from record value.",
1218
0
     function );
1219
1220
0
    return( -1 );
1221
0
  }
1222
0
  return( result );
1223
0
}
1224
1225
/* Retrieves the data as an UTF-16 encoded string
1226
 * The function uses the codepage in the column definition if necessary
1227
 * The size should include the end of string character
1228
 * Returns 1 if successful, 0 if value is NULL or -1 on error
1229
 */
1230
int libesedb_long_value_get_utf16_string(
1231
     libesedb_long_value_t *long_value,
1232
     uint16_t *utf16_string,
1233
     size_t utf16_string_size,
1234
     libcerror_error_t **error )
1235
0
{
1236
0
  libesedb_internal_long_value_t *internal_long_value = NULL;
1237
0
  libfvalue_value_t *record_value                     = NULL;
1238
0
  static char *function                               = "libesedb_long_value_get_utf16_string";
1239
0
  uint32_t column_type                                = 0;
1240
0
  int result                                          = 0;
1241
1242
0
  if( long_value == NULL )
1243
0
  {
1244
0
    libcerror_error_set(
1245
0
     error,
1246
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1247
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1248
0
     "%s: invalid long value.",
1249
0
     function );
1250
1251
0
    return( -1 );
1252
0
  }
1253
0
  internal_long_value = (libesedb_internal_long_value_t *) long_value;
1254
1255
0
  if( libesedb_catalog_definition_get_column_type(
1256
0
       internal_long_value->column_catalog_definition,
1257
0
       &column_type,
1258
0
       error ) != 1 )
1259
0
  {
1260
0
    libcerror_error_set(
1261
0
     error,
1262
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1263
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1264
0
     "%s: unable to retrieve catalog definition column type.",
1265
0
     function );
1266
1267
0
    return( -1 );
1268
0
  }
1269
0
  if( ( column_type != LIBESEDB_COLUMN_TYPE_TEXT )
1270
0
   && ( column_type != LIBESEDB_COLUMN_TYPE_LARGE_TEXT ) )
1271
0
  {
1272
0
    libcerror_error_set(
1273
0
     error,
1274
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1275
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
1276
0
     "%s: unsupported column type: %" PRIu32 ".",
1277
0
     function,
1278
0
     column_type );
1279
1280
0
    return( -1 );
1281
0
  }
1282
0
  if( libesedb_long_value_get_record_value(
1283
0
       internal_long_value,
1284
0
       &record_value,
1285
0
       error ) != 1 )
1286
0
  {
1287
0
    libcerror_error_set(
1288
0
     error,
1289
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1290
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1291
0
     "%s: unable to retrieve record value.",
1292
0
     function );
1293
1294
0
    return( -1 );
1295
0
  }
1296
0
  result = libesedb_record_value_get_utf16_string(
1297
0
            record_value,
1298
0
            utf16_string,
1299
0
            utf16_string_size,
1300
0
            error );
1301
1302
0
  if( result == -1 )
1303
0
  {
1304
0
    libcerror_error_set(
1305
0
     error,
1306
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1307
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1308
0
     "%s: unable to retrieve UTF-16 string from record value.",
1309
0
     function );
1310
1311
0
    return( -1 );
1312
0
  }
1313
0
  return( result );
1314
0
}
1315