Coverage Report

Created: 2026-08-31 07:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libevt/libevt/libevt_strings_array.c
Line
Count
Source
1
/*
2
 * Strings array functions
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 <common.h>
23
#include <memory.h>
24
#include <types.h>
25
26
#include "libevt_libcerror.h"
27
#include "libevt_libcnotify.h"
28
#include "libevt_libuna.h"
29
#include "libevt_strings_array.h"
30
31
/* Creates a strings array
32
 * Make sure the value strings_array is referencing, is set to NULL
33
 * Returns 1 if successful or -1 on error
34
 */
35
int libevt_strings_array_initialize(
36
     libevt_strings_array_t **strings_array,
37
     libcerror_error_t **error )
38
49.0k
{
39
49.0k
  static char *function = "libevt_strings_array_initialize";
40
41
49.0k
  if( strings_array == NULL )
42
0
  {
43
0
    libcerror_error_set(
44
0
     error,
45
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
46
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
47
0
     "%s: invalid strings array.",
48
0
     function );
49
50
0
    return( -1 );
51
0
  }
52
49.0k
  if( *strings_array != NULL )
53
0
  {
54
0
    libcerror_error_set(
55
0
     error,
56
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
57
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
58
0
     "%s: invalid strings array value already set.",
59
0
     function );
60
61
0
    return( -1 );
62
0
  }
63
49.0k
  *strings_array = memory_allocate_structure(
64
49.0k
                    libevt_strings_array_t );
65
66
49.0k
  if( *strings_array == NULL )
67
0
  {
68
0
    libcerror_error_set(
69
0
     error,
70
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
71
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
72
0
     "%s: unable to create strings array.",
73
0
     function );
74
75
0
    goto on_error;
76
0
  }
77
49.0k
  if( memory_set(
78
49.0k
       *strings_array,
79
49.0k
       0,
80
49.0k
       sizeof( libevt_strings_array_t ) ) == NULL )
81
0
  {
82
0
    libcerror_error_set(
83
0
     error,
84
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
85
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
86
0
     "%s: unable to clear strings array.",
87
0
     function );
88
89
0
    goto on_error;
90
0
  }
91
49.0k
  return( 1 );
92
93
0
on_error:
94
0
  if( *strings_array != NULL )
95
0
  {
96
0
    memory_free(
97
0
     *strings_array );
98
99
0
    *strings_array = NULL;
100
0
  }
101
0
  return( -1 );
102
49.0k
}
103
104
/* Frees a strings array
105
 * Returns 1 if successful or -1 on error
106
 */
107
int libevt_strings_array_free(
108
     libevt_strings_array_t **strings_array,
109
     libcerror_error_t **error )
110
49.0k
{
111
49.0k
  static char *function = "libevt_strings_array_free";
112
113
49.0k
  if( strings_array == NULL )
114
0
  {
115
0
    libcerror_error_set(
116
0
     error,
117
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
118
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
119
0
     "%s: invalid strings array.",
120
0
     function );
121
122
0
    return( -1 );
123
0
  }
124
49.0k
  if( *strings_array != NULL )
125
49.0k
  {
126
49.0k
    if( ( *strings_array )->string_sizes != NULL )
127
46.0k
    {
128
46.0k
      memory_free(
129
46.0k
       ( *strings_array )->string_sizes );
130
46.0k
    }
131
49.0k
    if( ( *strings_array )->strings != NULL )
132
46.0k
    {
133
46.0k
      memory_free(
134
46.0k
       ( *strings_array )->strings );
135
46.0k
    }
136
49.0k
    if( ( *strings_array )->strings_data != NULL )
137
46.0k
    {
138
46.0k
      memory_free(
139
46.0k
       ( *strings_array )->strings_data );
140
46.0k
    }
141
49.0k
    memory_free(
142
49.0k
     *strings_array );
143
144
49.0k
    *strings_array = NULL;
145
49.0k
  }
146
49.0k
  return( 1 );
147
49.0k
}
148
149
/* Reads the strings array data
150
 * Returns 1 if successful or -1 on error
151
 */
152
int libevt_strings_array_read_data(
153
     libevt_strings_array_t *strings_array,
154
     const uint8_t *data,
155
     size_t data_size,
156
     libcerror_error_t **error )
157
49.0k
{
158
49.0k
  static char *function = "libevt_strings_array_read_data";
159
49.0k
  size_t data_offset    = 0;
160
49.0k
  size_t string_offset  = 0;
161
49.0k
  int number_of_strings = 0;
162
49.0k
  int string_index      = 0;
163
164
49.0k
  if( strings_array == NULL )
165
0
  {
166
0
    libcerror_error_set(
167
0
     error,
168
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
169
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
170
0
     "%s: invalid strings array.",
171
0
     function );
172
173
0
    return( -1 );
174
0
  }
175
49.0k
  if( strings_array->strings_data != NULL )
176
0
  {
177
0
    libcerror_error_set(
178
0
     error,
179
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
180
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
181
0
     "%s: invalid strings array - strings data value already set.",
182
0
     function );
183
184
0
    return( -1 );
185
0
  }
186
49.0k
  if( data == NULL )
187
0
  {
188
0
    libcerror_error_set(
189
0
     error,
190
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
191
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
192
0
     "%s: invalid data.",
193
0
     function );
194
195
0
    return( -1 );
196
0
  }
197
49.0k
  if( ( data_size < 2 )
198
47.2k
   || ( data_size > (size_t) MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
199
1.76k
  {
200
1.76k
    libcerror_error_set(
201
1.76k
     error,
202
1.76k
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
203
1.76k
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
204
1.76k
     "%s: invalid data size value out of bounds.",
205
1.76k
     function );
206
207
1.76k
    return( -1 );
208
1.76k
  }
209
47.2k
  if( ( data_size % 2 ) != 0 )
210
1.21k
  {
211
1.21k
    libcerror_error_set(
212
1.21k
     error,
213
1.21k
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
214
1.21k
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
215
1.21k
     "%s: invalid data size - value must be a multitude of 2.",
216
1.21k
     function );
217
218
1.21k
    return( -1 );
219
1.21k
  }
220
#if defined( HAVE_DEBUG_OUTPUT )
221
  if( libcnotify_verbose != 0 )
222
  {
223
    libcnotify_printf(
224
     "%s: strings array data:\n",
225
     function );
226
    libcnotify_print_data(
227
     data,
228
     data_size,
229
     0 );
230
  }
231
#endif
232
46.0k
  for( data_offset = 0;
233
12.3M
       data_offset < data_size;
234
12.3M
       data_offset += 2 )
235
12.3M
  {
236
12.3M
    if( ( data[ data_offset ] == 0 )
237
6.50M
     && ( data[ data_offset + 1 ] == 0 ) )
238
5.44M
    {
239
5.44M
      number_of_strings++;
240
5.44M
    }
241
12.3M
  }
242
#if defined( HAVE_DEBUG_OUTPUT )
243
  if( libcnotify_verbose != 0 )
244
  {
245
    libcnotify_printf(
246
     "%s: number of strings\t\t\t: %d\n",
247
     function,
248
     number_of_strings );
249
250
    libcnotify_printf(
251
     "\n" );
252
  }
253
#endif
254
46.0k
  strings_array->strings_data = (uint8_t *) memory_allocate(
255
46.0k
                                             sizeof( uint8_t ) * data_size );
256
257
46.0k
  if( strings_array->strings_data == NULL )
258
0
  {
259
0
    libcerror_error_set(
260
0
     error,
261
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
262
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
263
0
     "%s: unable to create strings data.",
264
0
     function );
265
266
0
    goto on_error;
267
0
  }
268
46.0k
  if( memory_copy(
269
46.0k
       strings_array->strings_data,
270
46.0k
       data,
271
46.0k
       sizeof( uint8_t ) * data_size ) == NULL )
272
0
  {
273
0
    libcerror_error_set(
274
0
     error,
275
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
276
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
277
0
     "%s: unable to copy strings data.",
278
0
     function );
279
280
0
    goto on_error;
281
0
  }
282
46.0k
  strings_array->strings_data_size = data_size;
283
284
46.0k
  strings_array->strings = (uint8_t **) memory_allocate(
285
46.0k
                                         sizeof( uint8_t* ) * number_of_strings );
286
287
46.0k
  if( strings_array->strings == NULL )
288
0
  {
289
0
    libcerror_error_set(
290
0
     error,
291
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
292
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
293
0
     "%s: unable to create strings.",
294
0
     function );
295
296
0
    goto on_error;
297
0
  }
298
46.0k
  if( memory_set(
299
46.0k
       strings_array->strings,
300
46.0k
       0,
301
46.0k
       sizeof( uint8_t* ) * number_of_strings ) == NULL )
302
0
  {
303
0
    libcerror_error_set(
304
0
     error,
305
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
306
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
307
0
     "%s: unable to clear strings.",
308
0
     function );
309
310
0
    goto on_error;
311
0
  }
312
46.0k
  strings_array->string_sizes = (size_t *) memory_allocate(
313
46.0k
                                            sizeof( size_t ) * number_of_strings );
314
315
46.0k
  if( strings_array->string_sizes == NULL )
316
0
  {
317
0
    libcerror_error_set(
318
0
     error,
319
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
320
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
321
0
     "%s: unable to create string sizes.",
322
0
     function );
323
324
0
    goto on_error;
325
0
  }
326
46.0k
  if( memory_set(
327
46.0k
       strings_array->string_sizes,
328
46.0k
       0,
329
46.0k
       sizeof( uint8_t* ) * number_of_strings ) == NULL )
330
0
  {
331
0
    libcerror_error_set(
332
0
     error,
333
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
334
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
335
0
     "%s: unable to clear string sizes.",
336
0
     function );
337
338
0
    goto on_error;
339
0
  }
340
46.0k
  for( data_offset = 0;
341
12.3M
       data_offset < strings_array->strings_data_size;
342
12.3M
       data_offset += 2 )
343
12.3M
  {
344
12.3M
    if( ( strings_array->strings_data[ data_offset ] == 0 )
345
6.50M
     && ( strings_array->strings_data[ data_offset + 1 ] == 0 ) )
346
5.44M
    {
347
5.44M
      if( string_index >= number_of_strings )
348
0
      {
349
0
        libcerror_error_set(
350
0
         error,
351
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
352
0
         LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
353
0
         "%s: invalid string index value out of bounds.",
354
0
         function );
355
356
0
        goto on_error;
357
0
      }
358
5.44M
      strings_array->strings[ string_index ]      = &( strings_array->strings_data[ string_offset ] );
359
5.44M
      strings_array->string_sizes[ string_index ] = ( data_offset + 2 ) - string_offset;
360
361
#if defined( HAVE_DEBUG_OUTPUT )
362
      if( libcnotify_verbose != 0 )
363
      {
364
        libcnotify_printf(
365
         "%s: string: %d data:\n",
366
         function,
367
         string_index );
368
        libcnotify_print_data(
369
         strings_array->strings[ string_index ],
370
         strings_array->string_sizes[ string_index ],
371
         0 );
372
      }
373
#endif
374
5.44M
      string_offset = data_offset + 2;
375
376
5.44M
      string_index++;
377
5.44M
    }
378
12.3M
  }
379
46.0k
  strings_array->number_of_strings = number_of_strings;
380
381
46.0k
  return( 1 );
382
383
0
on_error:
384
0
  if( strings_array->string_sizes != NULL )
385
0
  {
386
0
    memory_free(
387
0
     strings_array->string_sizes );
388
389
0
    strings_array->string_sizes = NULL;
390
0
  }
391
0
  if( strings_array->strings != NULL )
392
0
  {
393
0
    memory_free(
394
0
     strings_array->strings );
395
396
0
    strings_array->strings = NULL;
397
0
  }
398
0
  if( strings_array->strings_data != NULL )
399
0
  {
400
0
    memory_free(
401
0
     strings_array->strings_data );
402
403
0
    strings_array->strings_data = NULL;
404
0
  }
405
0
  strings_array->strings_data_size = 0;
406
407
0
  return( -1 );
408
46.0k
}
409
410
/* Retrieves the number of strings
411
 * Returns 1 if successful or -1 on error
412
 */
413
int libevt_strings_array_get_number_of_strings(
414
     libevt_strings_array_t *strings_array,
415
     int *number_of_strings,
416
     libcerror_error_t **error )
417
0
{
418
0
  static char *function = "libevt_strings_array_get_number_of_strings";
419
420
0
  if( strings_array == NULL )
421
0
  {
422
0
    libcerror_error_set(
423
0
     error,
424
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
425
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
426
0
     "%s: invalid strings array.",
427
0
     function );
428
429
0
    return( -1 );
430
0
  }
431
0
  if( number_of_strings == NULL )
432
0
  {
433
0
    libcerror_error_set(
434
0
     error,
435
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
436
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
437
0
     "%s: invalid number of strings.",
438
0
     function );
439
440
0
    return( -1 );
441
0
  }
442
0
  *number_of_strings = strings_array->number_of_strings;
443
444
0
  return( 1 );
445
0
}
446
447
/* Retrieves the size of a specific UTF-8 encoded string
448
 * The returned size includes the end of string character
449
 * Returns 1 if successful or -1 on error
450
 */
451
int libevt_strings_array_get_utf8_string_size(
452
     libevt_strings_array_t *strings_array,
453
     int string_index,
454
     size_t *utf8_string_size,
455
     libcerror_error_t **error )
456
0
{
457
0
  static char *function = "libevt_strings_array_get_utf8_string_size";
458
459
0
  if( strings_array == NULL )
460
0
  {
461
0
    libcerror_error_set(
462
0
     error,
463
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
464
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
465
0
     "%s: invalid record values.",
466
0
     function );
467
468
0
    return( -1 );
469
0
  }
470
0
  if( strings_array->strings == NULL )
471
0
  {
472
0
    libcerror_error_set(
473
0
     error,
474
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
475
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
476
0
     "%s: invalid string index value out of bounds.",
477
0
     function );
478
479
0
    return( -1 );
480
0
  }
481
0
  if( ( string_index < 0 )
482
0
   || ( string_index >= strings_array->number_of_strings ) )
483
0
  {
484
0
    libcerror_error_set(
485
0
     error,
486
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
487
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
488
0
     "%s: invalid strings index value out of bounds.",
489
0
     function );
490
491
0
    return( -1 );
492
0
  }
493
0
  if( libuna_utf8_string_size_from_utf16_stream(
494
0
       strings_array->strings[ string_index ],
495
0
       strings_array->string_sizes[ string_index ],
496
0
       LIBUNA_ENDIAN_LITTLE,
497
0
       utf8_string_size,
498
0
       error ) != 1 )
499
0
  {
500
0
    libcerror_error_set(
501
0
     error,
502
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
503
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
504
0
     "%s: unable to determine size of UTF-8 string: %d.",
505
0
     function,
506
0
     string_index );
507
508
0
    return( -1 );
509
0
  }
510
0
  return( 1 );
511
0
}
512
513
/* Retrieves a specific UTF-8 encoded string
514
 * The size should include the end of string character
515
 * Returns 1 if successful or -1 on error
516
 */
517
int libevt_strings_array_get_utf8_string(
518
     libevt_strings_array_t *strings_array,
519
     int string_index,
520
     uint8_t *utf8_string,
521
     size_t utf8_string_size,
522
     libcerror_error_t **error )
523
0
{
524
0
  static char *function = "libevt_values_record_get_utf8_string";
525
526
0
  if( strings_array == NULL )
527
0
  {
528
0
    libcerror_error_set(
529
0
     error,
530
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
531
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
532
0
     "%s: invalid record values.",
533
0
     function );
534
535
0
    return( -1 );
536
0
  }
537
0
  if( strings_array->strings == NULL )
538
0
  {
539
0
    libcerror_error_set(
540
0
     error,
541
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
542
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
543
0
     "%s: invalid string index value out of bounds.",
544
0
     function );
545
546
0
    return( -1 );
547
0
  }
548
0
  if( ( string_index < 0 )
549
0
   || ( string_index >= strings_array->number_of_strings ) )
550
0
  {
551
0
    libcerror_error_set(
552
0
     error,
553
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
554
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
555
0
     "%s: invalid strings index value out of bounds.",
556
0
     function );
557
558
0
    return( -1 );
559
0
  }
560
0
  if( libuna_utf8_string_copy_from_utf16_stream(
561
0
       (libuna_utf8_character_t *) utf8_string,
562
0
       utf8_string_size,
563
0
       strings_array->strings[ string_index ],
564
0
       strings_array->string_sizes[ string_index ],
565
0
       LIBUNA_ENDIAN_LITTLE,
566
0
       error ) != 1 )
567
0
  {
568
0
    libcerror_error_set(
569
0
     error,
570
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
571
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
572
0
     "%s: unable to set UTF-8 string: %d.",
573
0
     function,
574
0
     string_index );
575
576
0
    return( -1 );
577
0
  }
578
0
  return( 1 );
579
0
}
580
581
/* Retrieves the size of a specific UTF-16 encoded string
582
 * The returned size includes the end of string character
583
 * Returns 1 if successful or -1 on error
584
 */
585
int libevt_strings_array_get_utf16_string_size(
586
     libevt_strings_array_t *strings_array,
587
     int string_index,
588
     size_t *utf16_string_size,
589
     libcerror_error_t **error )
590
0
{
591
0
  static char *function = "libevt_strings_array_get_utf16_string_size";
592
593
0
  if( strings_array == NULL )
594
0
  {
595
0
    libcerror_error_set(
596
0
     error,
597
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
598
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
599
0
     "%s: invalid record values.",
600
0
     function );
601
602
0
    return( -1 );
603
0
  }
604
0
  if( strings_array->strings == NULL )
605
0
  {
606
0
    libcerror_error_set(
607
0
     error,
608
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
609
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
610
0
     "%s: invalid string index value out of bounds.",
611
0
     function );
612
613
0
    return( -1 );
614
0
  }
615
0
  if( ( string_index < 0 )
616
0
   || ( string_index >= strings_array->number_of_strings ) )
617
0
  {
618
0
    libcerror_error_set(
619
0
     error,
620
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
621
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
622
0
     "%s: invalid strings index value out of bounds.",
623
0
     function );
624
625
0
    return( -1 );
626
0
  }
627
0
  if( libuna_utf16_string_size_from_utf16_stream(
628
0
       strings_array->strings[ string_index ],
629
0
       strings_array->string_sizes[ string_index ],
630
0
       LIBUNA_ENDIAN_LITTLE,
631
0
       utf16_string_size,
632
0
       error ) != 1 )
633
0
  {
634
0
    libcerror_error_set(
635
0
     error,
636
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
637
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
638
0
     "%s: unable to determine size of UTF-16 string: %d.",
639
0
     function,
640
0
     string_index );
641
642
0
    return( -1 );
643
0
  }
644
0
  return( 1 );
645
0
}
646
647
/* Retrieves a specific UTF-16 encoded string
648
 * The size should include the end of string character
649
 * Returns 1 if successful or -1 on error
650
 */
651
int libevt_strings_array_get_utf16_string(
652
     libevt_strings_array_t *strings_array,
653
     int string_index,
654
     uint16_t *utf16_string,
655
     size_t utf16_string_size,
656
     libcerror_error_t **error )
657
0
{
658
0
  static char *function = "libevt_values_record_get_utf16_string";
659
660
0
  if( strings_array == NULL )
661
0
  {
662
0
    libcerror_error_set(
663
0
     error,
664
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
665
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
666
0
     "%s: invalid record values.",
667
0
     function );
668
669
0
    return( -1 );
670
0
  }
671
0
  if( strings_array->strings == NULL )
672
0
  {
673
0
    libcerror_error_set(
674
0
     error,
675
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
676
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
677
0
     "%s: invalid string index value out of bounds.",
678
0
     function );
679
680
0
    return( -1 );
681
0
  }
682
0
  if( ( string_index < 0 )
683
0
   || ( string_index >= strings_array->number_of_strings ) )
684
0
  {
685
0
    libcerror_error_set(
686
0
     error,
687
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
688
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
689
0
     "%s: invalid strings index value out of bounds.",
690
0
     function );
691
692
0
    return( -1 );
693
0
  }
694
0
  if( libuna_utf16_string_copy_from_utf16_stream(
695
0
       (libuna_utf16_character_t *) utf16_string,
696
0
       utf16_string_size,
697
0
       strings_array->strings[ string_index ],
698
0
       strings_array->string_sizes[ string_index ],
699
0
       LIBUNA_ENDIAN_LITTLE,
700
0
       error ) != 1 )
701
0
  {
702
0
    libcerror_error_set(
703
0
     error,
704
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
705
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
706
0
     "%s: unable to set UTF-16 string: %d.",
707
0
     function,
708
0
     string_index );
709
710
0
    return( -1 );
711
0
  }
712
0
  return( 1 );
713
0
}
714