Coverage Report

Created: 2026-02-19 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libewf/libewf/libewf_lef_permission.c
Line
Count
Source
1
/*
2
 * Logical Evidence File (LEF) permission functions
3
 *
4
 * Copyright (C) 2006-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 <memory.h>
24
#include <types.h>
25
26
#include "libewf_definitions.h"
27
#include "libewf_lef_permission.h"
28
#include "libewf_libcerror.h"
29
#include "libewf_libcnotify.h"
30
#include "libewf_libfvalue.h"
31
#include "libewf_serialized_string.h"
32
33
/* Creates a permission
34
 * Make sure the value lef_permission is referencing, is set to NULL
35
 * Returns 1 if successful or -1 on error
36
 */
37
int libewf_lef_permission_initialize(
38
     libewf_lef_permission_t **lef_permission,
39
     libcerror_error_t **error )
40
0
{
41
0
  static char *function = "libewf_lef_permission_initialize";
42
43
0
  if( lef_permission == NULL )
44
0
  {
45
0
    libcerror_error_set(
46
0
     error,
47
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
48
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
49
0
     "%s: invalid permission.",
50
0
     function );
51
52
0
    return( -1 );
53
0
  }
54
0
  if( *lef_permission != NULL )
55
0
  {
56
0
    libcerror_error_set(
57
0
     error,
58
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
59
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
60
0
     "%s: invalid permission value already set.",
61
0
     function );
62
63
0
    return( -1 );
64
0
  }
65
0
  *lef_permission = memory_allocate_structure(
66
0
                     libewf_lef_permission_t );
67
68
0
  if( *lef_permission == NULL )
69
0
  {
70
0
    libcerror_error_set(
71
0
     error,
72
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
73
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
74
0
     "%s: unable to create permission.",
75
0
     function );
76
77
0
    goto on_error;
78
0
  }
79
0
  if( memory_set(
80
0
       *lef_permission,
81
0
       0,
82
0
       sizeof( libewf_lef_permission_t ) ) == NULL )
83
0
  {
84
0
    libcerror_error_set(
85
0
     error,
86
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
87
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
88
0
     "%s: unable to clear permission.",
89
0
     function );
90
91
0
    memory_free(
92
0
     *lef_permission );
93
94
0
    *lef_permission = NULL;
95
96
0
    return( -1 );
97
0
  }
98
0
  if( libewf_serialized_string_initialize(
99
0
       &( ( *lef_permission )->name ),
100
0
       error ) != 1 )
101
0
  {
102
0
    libcerror_error_set(
103
0
     error,
104
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
105
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
106
0
     "%s: unable to create name string.",
107
0
     function );
108
109
0
    goto on_error;
110
0
  }
111
0
  if( libewf_serialized_string_initialize(
112
0
       &( ( *lef_permission )->identifier ),
113
0
       error ) != 1 )
114
0
  {
115
0
    libcerror_error_set(
116
0
     error,
117
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
118
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
119
0
     "%s: unable to create identifier string.",
120
0
     function );
121
122
0
    goto on_error;
123
0
  }
124
0
  return( 1 );
125
126
0
on_error:
127
0
  if( *lef_permission != NULL )
128
0
  {
129
0
    if( ( *lef_permission )->name != NULL )
130
0
    {
131
0
      libewf_serialized_string_free(
132
0
       &( ( *lef_permission )->name ),
133
0
       NULL );
134
0
    }
135
0
    memory_free(
136
0
     *lef_permission );
137
138
0
    *lef_permission = NULL;
139
0
  }
140
0
  return( -1 );
141
0
}
142
143
/* Frees a permission
144
 * Returns 1 if successful or -1 on error
145
 */
146
int libewf_lef_permission_free(
147
     libewf_lef_permission_t **lef_permission,
148
     libcerror_error_t **error )
149
0
{
150
0
  static char *function = "libewf_lef_permission_free";
151
0
  int result            = 1;
152
153
0
  if( lef_permission == NULL )
154
0
  {
155
0
    libcerror_error_set(
156
0
     error,
157
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
158
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
159
0
     "%s: invalid permission.",
160
0
     function );
161
162
0
    return( -1 );
163
0
  }
164
0
  if( *lef_permission != NULL )
165
0
  {
166
0
    if( ( *lef_permission )->name != NULL )
167
0
    {
168
0
      if( libewf_serialized_string_free(
169
0
           &( ( *lef_permission )->name ),
170
0
           error ) != 1 )
171
0
      {
172
0
        libcerror_error_set(
173
0
         error,
174
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
175
0
         LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
176
0
         "%s: unable to free name string.",
177
0
         function );
178
179
0
        result = -1;
180
0
      }
181
0
    }
182
0
    if( ( *lef_permission )->identifier != NULL )
183
0
    {
184
0
      if( libewf_serialized_string_free(
185
0
           &( ( *lef_permission )->identifier ),
186
0
           error ) != 1 )
187
0
      {
188
0
        libcerror_error_set(
189
0
         error,
190
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
191
0
         LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
192
0
         "%s: unable to free identifier string.",
193
0
         function );
194
195
0
        result = -1;
196
0
      }
197
0
    }
198
0
    memory_free(
199
0
     *lef_permission );
200
201
0
    *lef_permission = NULL;
202
0
  }
203
0
  return( result );
204
0
}
205
206
/* Clones the permission
207
 * Returns 1 if successful or -1 on error
208
 */
209
int libewf_lef_permission_clone(
210
     libewf_lef_permission_t **destination_lef_permission,
211
     libewf_lef_permission_t *source_lef_permission,
212
     libcerror_error_t **error )
213
0
{
214
0
  static char *function = "libewf_lef_permission_clone";
215
216
0
  if( destination_lef_permission == NULL )
217
0
  {
218
0
    libcerror_error_set(
219
0
     error,
220
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
221
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
222
0
     "%s: invalid destination permission.",
223
0
     function );
224
225
0
    return( -1 );
226
0
  }
227
0
  if( *destination_lef_permission != NULL )
228
0
  {
229
0
    libcerror_error_set(
230
0
     error,
231
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
232
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
233
0
     "%s: invalid destination permission value already set.",
234
0
     function );
235
236
0
    return( -1 );
237
0
  }
238
0
  if( source_lef_permission == NULL )
239
0
  {
240
0
    *destination_lef_permission = NULL;
241
242
0
    return( 1 );
243
0
  }
244
0
  *destination_lef_permission = memory_allocate_structure(
245
0
                                 libewf_lef_permission_t );
246
247
0
  if( *destination_lef_permission == NULL )
248
0
  {
249
0
    libcerror_error_set(
250
0
     error,
251
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
252
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
253
0
     "%s: unable to create destination permission.",
254
0
     function );
255
256
0
    goto on_error;
257
0
  }
258
0
  if( memory_copy(
259
0
       *destination_lef_permission,
260
0
       source_lef_permission,
261
0
       sizeof( libewf_lef_permission_t ) ) == NULL )
262
0
  {
263
0
    libcerror_error_set(
264
0
     error,
265
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
266
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
267
0
     "%s: unable to copy source to destination permission.",
268
0
     function );
269
270
0
    memory_free(
271
0
     *destination_lef_permission );
272
273
0
    *destination_lef_permission = NULL;
274
275
0
    return( -1 );
276
0
  }
277
0
  ( *destination_lef_permission )->name       = NULL;
278
0
  ( *destination_lef_permission )->identifier = NULL;
279
280
0
  if( libewf_serialized_string_clone(
281
0
       &( ( *destination_lef_permission )->name ),
282
0
       source_lef_permission->name,
283
0
       error ) != 1 )
284
0
  {
285
0
    libcerror_error_set(
286
0
     error,
287
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
288
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
289
0
     "%s: unable to clone destination name string.",
290
0
     function );
291
292
0
    goto on_error;
293
0
  }
294
0
  if( libewf_serialized_string_clone(
295
0
       &( ( *destination_lef_permission )->identifier ),
296
0
       source_lef_permission->identifier,
297
0
       error ) != 1 )
298
0
  {
299
0
    libcerror_error_set(
300
0
     error,
301
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
302
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
303
0
     "%s: unable to clone destination identifier string.",
304
0
     function );
305
306
0
    goto on_error;
307
0
  }
308
0
  return( 1 );
309
310
0
on_error:
311
0
  if( *destination_lef_permission != NULL )
312
0
  {
313
0
    libewf_lef_permission_free(
314
0
     destination_lef_permission,
315
0
     NULL );
316
0
  }
317
0
  return( -1 );
318
0
}
319
320
/* Reads a permission
321
 * Returns 1 if successful or -1 on error
322
 */
323
int libewf_lef_permission_read_data(
324
     libewf_lef_permission_t *lef_permission,
325
     libfvalue_split_utf8_string_t *types,
326
     const uint8_t *data,
327
     size_t data_size,
328
     libcerror_error_t **error )
329
0
{
330
0
  libfvalue_split_utf8_string_t *values = NULL;
331
0
  uint8_t *type_string                  = NULL;
332
0
  uint8_t *value_string                 = NULL;
333
0
  static char *function                 = "libewf_lef_permission_read_data";
334
0
  size_t type_string_size               = 0;
335
0
  size_t value_string_size              = 0;
336
0
  uint64_t value_64bit                  = 0;
337
0
  int number_of_types                   = 0;
338
0
  int number_of_values                  = 0;
339
0
  int value_index                       = 0;
340
341
0
  if( lef_permission == NULL )
342
0
  {
343
0
    libcerror_error_set(
344
0
     error,
345
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
346
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
347
0
     "%s: invalid permission.",
348
0
     function );
349
350
0
    return( -1 );
351
0
  }
352
0
  if( libfvalue_split_utf8_string_get_number_of_segments(
353
0
       types,
354
0
       &number_of_types,
355
0
       error ) != 1 )
356
0
  {
357
0
    libcerror_error_set(
358
0
     error,
359
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
360
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
361
0
     "%s: unable to retrieve number of types",
362
0
     function );
363
364
0
    goto on_error;
365
0
  }
366
0
  if( libfvalue_utf8_string_split(
367
0
       data,
368
0
       data_size,
369
0
       (uint8_t) '\t',
370
0
       &values,
371
0
       error ) != 1 )
372
0
  {
373
0
    libcerror_error_set(
374
0
     error,
375
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
376
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
377
0
     "%s: unable to split data into string values.",
378
0
     function );
379
380
0
    goto on_error;
381
0
  }
382
0
  if( libfvalue_split_utf8_string_get_number_of_segments(
383
0
       values,
384
0
       &number_of_values,
385
0
       error ) != 1 )
386
0
  {
387
0
    libcerror_error_set(
388
0
     error,
389
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
390
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
391
0
     "%s: unable to retrieve number of values",
392
0
     function );
393
394
0
    goto on_error;
395
0
  }
396
0
  if( number_of_types != number_of_values )
397
0
  {
398
0
    libcerror_error_set(
399
0
     error,
400
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
401
0
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
402
0
     "%s: mismatch in number of types and values.",
403
0
     function );
404
405
0
    goto on_error;
406
0
  }
407
0
  for( value_index = 0;
408
0
       value_index < number_of_types;
409
0
       value_index++ )
410
0
  {
411
0
    if( libfvalue_split_utf8_string_get_segment_by_index(
412
0
         types,
413
0
         value_index,
414
0
         &type_string,
415
0
         &type_string_size,
416
0
         error ) != 1 )
417
0
    {
418
0
      libcerror_error_set(
419
0
       error,
420
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
421
0
       LIBCERROR_RUNTIME_ERROR_GET_FAILED,
422
0
       "%s: unable to retrieve type string: %d.",
423
0
       function,
424
0
       value_index );
425
426
0
      goto on_error;
427
0
    }
428
0
    if( ( type_string == NULL )
429
0
     || ( type_string_size < 2 )
430
0
     || ( type_string[ 0 ] == 0 ) )
431
0
    {
432
0
      libcerror_error_set(
433
0
       error,
434
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
435
0
       LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
436
0
       "%s: missing type string: %d.",
437
0
       function,
438
0
       value_index );
439
440
0
      goto on_error;
441
0
    }
442
0
    if( value_index >= number_of_values )
443
0
    {
444
0
      value_string      = NULL;
445
0
      value_string_size = 0;
446
0
    }
447
0
    else
448
0
    {
449
0
      if( libfvalue_split_utf8_string_get_segment_by_index(
450
0
           values,
451
0
           value_index,
452
0
           &value_string,
453
0
           &value_string_size,
454
0
           error ) != 1 )
455
0
      {
456
0
        libcerror_error_set(
457
0
         error,
458
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
459
0
         LIBCERROR_RUNTIME_ERROR_GET_FAILED,
460
0
         "%s: unable to retrieve value string: %d.",
461
0
         function,
462
0
         value_index );
463
464
0
        goto on_error;
465
0
      }
466
0
      if( ( value_string == NULL )
467
0
       || ( value_string_size < 2 )
468
0
       || ( value_string[ 0 ] == 0 ) )
469
0
      {
470
0
        value_string      = NULL;
471
0
        value_string_size = 0;
472
0
      }
473
0
    }
474
#if defined( HAVE_DEBUG_OUTPUT )
475
    if( libcnotify_verbose != 0 )
476
    {
477
      libcnotify_printf(
478
       "%s: type: %3s with value\t\t\t:",
479
       function,
480
       (char *) type_string );
481
482
      if( value_string != NULL )
483
      {
484
        libcnotify_printf(
485
         " %s",
486
         (char *) value_string );
487
      }
488
      libcnotify_printf(
489
       "\n" );
490
    }
491
#endif
492
0
    if( ( value_string == NULL )
493
0
     || ( value_string_size == 0 ) )
494
0
    {
495
      /* Ignore empty values
496
       */
497
0
    }
498
0
    else if( type_string_size == 4 )
499
0
    {
500
0
      if( ( type_string[ 0 ] == (uint8_t) 'n' )
501
0
       && ( type_string[ 1 ] == (uint8_t) 't' )
502
0
       && ( type_string[ 2 ] == (uint8_t) 'a' ) )
503
0
      {
504
0
        if( libfvalue_utf8_string_copy_to_integer(
505
0
             value_string,
506
0
             value_string_size,
507
0
             &value_64bit,
508
0
             64,
509
0
             LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED,
510
0
             error ) != 1 )
511
0
        {
512
0
          libcerror_error_set(
513
0
           error,
514
0
           LIBCERROR_ERROR_DOMAIN_MEMORY,
515
0
           LIBCERROR_MEMORY_ERROR_SET_FAILED,
516
0
           "%s: unable to set access mask.",
517
0
           function );
518
519
0
          goto on_error;
520
0
        }
521
0
        if( value_64bit > (uint64_t) UINT32_MAX )
522
0
        {
523
0
          libcerror_error_set(
524
0
           error,
525
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
526
0
           LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
527
0
           "%s: invalid access mask value out of bounds.",
528
0
           function );
529
530
0
          goto on_error;
531
0
        }
532
0
        lef_permission->access_mask = (uint32_t) value_64bit;
533
0
      }
534
0
      else if( ( type_string[ 0 ] == (uint8_t) 'n' )
535
0
            && ( type_string[ 1 ] == (uint8_t) 't' )
536
0
            && ( type_string[ 2 ] == (uint8_t) 'i' ) )
537
0
      {
538
0
        if( libfvalue_utf8_string_copy_to_integer(
539
0
             value_string,
540
0
             value_string_size,
541
0
             &value_64bit,
542
0
             64,
543
0
             LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED,
544
0
             error ) != 1 )
545
0
        {
546
0
          libcerror_error_set(
547
0
           error,
548
0
           LIBCERROR_ERROR_DOMAIN_MEMORY,
549
0
           LIBCERROR_MEMORY_ERROR_SET_FAILED,
550
0
           "%s: unable to set ACE flags.",
551
0
           function );
552
553
0
          goto on_error;
554
0
        }
555
0
        if( value_64bit > (uint64_t) UINT32_MAX )
556
0
        {
557
0
          libcerror_error_set(
558
0
           error,
559
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
560
0
           LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
561
0
           "%s: invalid ACE flags value out of bounds.",
562
0
           function );
563
564
0
          goto on_error;
565
0
        }
566
0
        lef_permission->ace_flags = (uint32_t) value_64bit;
567
0
      }
568
0
      else if( ( type_string[ 0 ] == (uint8_t) 'n' )
569
0
            && ( type_string[ 1 ] == (uint8_t) 't' )
570
0
            && ( type_string[ 2 ] == (uint8_t) 's' ) )
571
0
      {
572
/* TODO implement */
573
0
      }
574
0
    }
575
0
    else if( type_string_size == 3 )
576
0
    {
577
0
      if( ( type_string[ 0 ] == (uint8_t) 'p' )
578
0
       && ( type_string[ 1 ] == (uint8_t) 'r' ) )
579
0
      {
580
0
        if( libfvalue_utf8_string_copy_to_integer(
581
0
             value_string,
582
0
             value_string_size,
583
0
             &value_64bit,
584
0
             64,
585
0
             LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED,
586
0
             error ) != 1 )
587
0
        {
588
0
          libcerror_error_set(
589
0
           error,
590
0
           LIBCERROR_ERROR_DOMAIN_MEMORY,
591
0
           LIBCERROR_MEMORY_ERROR_SET_FAILED,
592
0
           "%s: unable to set property type.",
593
0
           function );
594
595
0
          goto on_error;
596
0
        }
597
0
        if( value_64bit > (uint64_t) UINT32_MAX )
598
0
        {
599
0
          libcerror_error_set(
600
0
           error,
601
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
602
0
           LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
603
0
           "%s: invalid property type value out of bounds.",
604
0
           function );
605
606
0
          goto on_error;
607
0
        }
608
0
        lef_permission->property_type = (uint32_t) value_64bit;
609
0
      }
610
0
    }
611
0
    else if( type_string_size == 2 )
612
0
    {
613
0
      if( type_string[ 0 ] == (uint8_t) 'n' )
614
0
      {
615
0
        if( libewf_serialized_string_read_data(
616
0
             lef_permission->name,
617
0
             value_string,
618
0
             value_string_size - 1,
619
0
             LIBEWF_VALUE_DATA_TYPE_UTF8,
620
0
             error ) != 1 )
621
0
        {
622
0
          libcerror_error_set(
623
0
           error,
624
0
           LIBCERROR_ERROR_DOMAIN_IO,
625
0
           LIBCERROR_IO_ERROR_READ_FAILED,
626
0
           "%s: unable to read name string.",
627
0
           function );
628
629
0
          goto on_error;
630
0
        }
631
0
      }
632
0
      else if( type_string[ 0 ] == (uint8_t) 's' )
633
0
      {
634
0
        if( libewf_serialized_string_read_data(
635
0
             lef_permission->identifier,
636
0
             value_string,
637
0
             value_string_size - 1,
638
0
             LIBEWF_VALUE_DATA_TYPE_UTF8,
639
0
             error ) != 1 )
640
0
        {
641
0
          libcerror_error_set(
642
0
           error,
643
0
           LIBCERROR_ERROR_DOMAIN_IO,
644
0
           LIBCERROR_IO_ERROR_READ_FAILED,
645
0
           "%s: unable to read identifier string.",
646
0
           function );
647
648
0
          goto on_error;
649
0
        }
650
0
      }
651
0
    }
652
0
  }
653
#if defined( HAVE_DEBUG_OUTPUT )
654
  if( libcnotify_verbose != 0 )
655
  {
656
    libcnotify_printf(
657
     "\n" );
658
  }
659
#endif
660
0
  if( libfvalue_split_utf8_string_free(
661
0
       &values,
662
0
       error ) != 1 )
663
0
  {
664
0
    libcerror_error_set(
665
0
     error,
666
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
667
0
     LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
668
0
     "%s: unable to free split values.",
669
0
     function );
670
671
0
    goto on_error;
672
0
  }
673
0
  return( 1 );
674
675
0
on_error:
676
0
  if( values != NULL )
677
0
  {
678
0
    libfvalue_split_utf8_string_free(
679
0
     &values,
680
0
     NULL );
681
0
  }
682
0
  return( -1 );
683
0
}
684
685
/* Retrieves the size of the UTF-8 encoded name
686
 * The returned size includes the end of string character
687
 * Returns 1 if successful, 0 if not set or -1 on error
688
 */
689
int libewf_lef_permission_get_utf8_name_size(
690
     libewf_lef_permission_t *lef_permission,
691
     size_t *utf8_string_size,
692
     libcerror_error_t **error )
693
0
{
694
0
  static char *function = "libewf_lef_permission_get_utf8_name_size";
695
0
  int result            = 0;
696
697
0
  if( lef_permission == NULL )
698
0
  {
699
0
    libcerror_error_set(
700
0
     error,
701
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
702
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
703
0
     "%s: invalid permission.",
704
0
     function );
705
706
0
    return( -1 );
707
0
  }
708
0
  result = libewf_serialized_string_get_utf8_string_size(
709
0
            lef_permission->name,
710
0
            utf8_string_size,
711
0
            error );
712
713
0
  if( result == -1 )
714
0
  {
715
0
    libcerror_error_set(
716
0
     error,
717
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
718
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
719
0
     "%s: unable to retrieve name UTF-8 string size.",
720
0
     function );
721
722
0
    return( -1 );
723
0
  }
724
0
  return( result );
725
0
}
726
727
/* Retrieves the UTF-8 encoded name
728
 * The size should include the end of string character
729
 * Returns 1 if successful, 0 if not set or -1 on error
730
 */
731
int libewf_lef_permission_get_utf8_name(
732
     libewf_lef_permission_t *lef_permission,
733
     uint8_t *utf8_string,
734
     size_t utf8_string_size,
735
     libcerror_error_t **error )
736
0
{
737
0
  static char *function = "libewf_lef_permission_get_utf8_name";
738
0
  int result            = 0;
739
740
0
  if( lef_permission == NULL )
741
0
  {
742
0
    libcerror_error_set(
743
0
     error,
744
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
745
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
746
0
     "%s: invalid permission.",
747
0
     function );
748
749
0
    return( -1 );
750
0
  }
751
0
  result = libewf_serialized_string_get_utf8_string(
752
0
            lef_permission->name,
753
0
            utf8_string,
754
0
            utf8_string_size,
755
0
            error );
756
757
0
  if( result == -1 )
758
0
  {
759
0
    libcerror_error_set(
760
0
     error,
761
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
762
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
763
0
     "%s: unable to copy name to UTF-8 string.",
764
0
     function );
765
766
0
    return( -1 );
767
0
  }
768
0
  return( result );
769
0
}
770
771
/* Retrieves the size of the UTF-16 encoded name
772
 * The returned size includes the end of string character
773
 * Returns 1 if successful, 0 if not set or -1 on error
774
 */
775
int libewf_lef_permission_get_utf16_name_size(
776
     libewf_lef_permission_t *lef_permission,
777
     size_t *utf16_string_size,
778
     libcerror_error_t **error )
779
0
{
780
0
  static char *function = "libewf_lef_permission_get_utf16_name_size";
781
0
  int result            = 0;
782
783
0
  if( lef_permission == NULL )
784
0
  {
785
0
    libcerror_error_set(
786
0
     error,
787
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
788
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
789
0
     "%s: invalid permission.",
790
0
     function );
791
792
0
    return( -1 );
793
0
  }
794
0
  result = libewf_serialized_string_get_utf16_string_size(
795
0
            lef_permission->name,
796
0
            utf16_string_size,
797
0
            error );
798
799
0
  if( result == -1 )
800
0
  {
801
0
    libcerror_error_set(
802
0
     error,
803
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
804
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
805
0
     "%s: unable to retrieve name UTF-16 string size.",
806
0
     function );
807
808
0
    return( -1 );
809
0
  }
810
0
  return( result );
811
0
}
812
813
/* Retrieves the UTF-16 encoded name
814
 * The size should include the end of string character
815
 * Returns 1 if successful, 0 if not set or -1 on error
816
 */
817
int libewf_lef_permission_get_utf16_name(
818
     libewf_lef_permission_t *lef_permission,
819
     uint16_t *utf16_string,
820
     size_t utf16_string_size,
821
     libcerror_error_t **error )
822
0
{
823
0
  static char *function = "libewf_lef_permission_get_utf16_name";
824
0
  int result            = 0;
825
826
0
  if( lef_permission == NULL )
827
0
  {
828
0
    libcerror_error_set(
829
0
     error,
830
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
831
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
832
0
     "%s: invalid permission.",
833
0
     function );
834
835
0
    return( -1 );
836
0
  }
837
0
  result = libewf_serialized_string_get_utf16_string(
838
0
            lef_permission->name,
839
0
            utf16_string,
840
0
            utf16_string_size,
841
0
            error );
842
843
0
  if( result == -1 )
844
0
  {
845
0
    libcerror_error_set(
846
0
     error,
847
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
848
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
849
0
     "%s: unable to copy name to UTF-16 string.",
850
0
     function );
851
852
0
    return( -1 );
853
0
  }
854
0
  return( result );
855
0
}
856
857
/* Retrieves the size of the UTF-8 encoded identifier
858
 * The returned size includes the end of string character
859
 * Returns 1 if successful, 0 if not set or -1 on error
860
 */
861
int libewf_lef_permission_get_utf8_identifier_size(
862
     libewf_lef_permission_t *lef_permission,
863
     size_t *utf8_string_size,
864
     libcerror_error_t **error )
865
0
{
866
0
  static char *function = "libewf_lef_permission_get_utf8_identifier_size";
867
0
  int result            = 0;
868
869
0
  if( lef_permission == NULL )
870
0
  {
871
0
    libcerror_error_set(
872
0
     error,
873
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
874
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
875
0
     "%s: invalid permission.",
876
0
     function );
877
878
0
    return( -1 );
879
0
  }
880
0
  result = libewf_serialized_string_get_utf8_string_size(
881
0
            lef_permission->identifier,
882
0
            utf8_string_size,
883
0
            error );
884
885
0
  if( result == -1 )
886
0
  {
887
0
    libcerror_error_set(
888
0
     error,
889
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
890
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
891
0
     "%s: unable to retrieve identifier UTF-8 string size.",
892
0
     function );
893
894
0
    return( -1 );
895
0
  }
896
0
  return( result );
897
0
}
898
899
/* Retrieves the UTF-8 encoded identifier
900
 * The size should include the end of string character
901
 * Returns 1 if successful, 0 if not set or -1 on error
902
 */
903
int libewf_lef_permission_get_utf8_identifier(
904
     libewf_lef_permission_t *lef_permission,
905
     uint8_t *utf8_string,
906
     size_t utf8_string_size,
907
     libcerror_error_t **error )
908
0
{
909
0
  static char *function = "libewf_lef_permission_get_utf8_identifier";
910
0
  int result            = 0;
911
912
0
  if( lef_permission == NULL )
913
0
  {
914
0
    libcerror_error_set(
915
0
     error,
916
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
917
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
918
0
     "%s: invalid permission.",
919
0
     function );
920
921
0
    return( -1 );
922
0
  }
923
0
  result = libewf_serialized_string_get_utf8_string(
924
0
            lef_permission->identifier,
925
0
            utf8_string,
926
0
            utf8_string_size,
927
0
            error );
928
929
0
  if( result == -1 )
930
0
  {
931
0
    libcerror_error_set(
932
0
     error,
933
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
934
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
935
0
     "%s: unable to copy identifier to UTF-8 string.",
936
0
     function );
937
938
0
    return( -1 );
939
0
  }
940
0
  return( result );
941
0
}
942
943
/* Retrieves the size of the UTF-16 encoded identifier
944
 * The returned size includes the end of string character
945
 * Returns 1 if successful, 0 if not set or -1 on error
946
 */
947
int libewf_lef_permission_get_utf16_identifier_size(
948
     libewf_lef_permission_t *lef_permission,
949
     size_t *utf16_string_size,
950
     libcerror_error_t **error )
951
0
{
952
0
  static char *function = "libewf_lef_permission_get_utf16_identifier_size";
953
0
  int result            = 0;
954
955
0
  if( lef_permission == NULL )
956
0
  {
957
0
    libcerror_error_set(
958
0
     error,
959
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
960
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
961
0
     "%s: invalid permission.",
962
0
     function );
963
964
0
    return( -1 );
965
0
  }
966
0
  result = libewf_serialized_string_get_utf16_string_size(
967
0
            lef_permission->identifier,
968
0
            utf16_string_size,
969
0
            error );
970
971
0
  if( result == -1 )
972
0
  {
973
0
    libcerror_error_set(
974
0
     error,
975
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
976
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
977
0
     "%s: unable to retrieve identifier UTF-16 string size.",
978
0
     function );
979
980
0
    return( -1 );
981
0
  }
982
0
  return( result );
983
0
}
984
985
/* Retrieves the UTF-16 encoded identifier
986
 * The size should include the end of string character
987
 * Returns 1 if successful, 0 if not set or -1 on error
988
 */
989
int libewf_lef_permission_get_utf16_identifier(
990
     libewf_lef_permission_t *lef_permission,
991
     uint16_t *utf16_string,
992
     size_t utf16_string_size,
993
     libcerror_error_t **error )
994
0
{
995
0
  static char *function = "libewf_lef_permission_get_utf16_identifier";
996
0
  int result            = 0;
997
998
0
  if( lef_permission == NULL )
999
0
  {
1000
0
    libcerror_error_set(
1001
0
     error,
1002
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1003
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1004
0
     "%s: invalid permission.",
1005
0
     function );
1006
1007
0
    return( -1 );
1008
0
  }
1009
0
  result = libewf_serialized_string_get_utf16_string(
1010
0
            lef_permission->identifier,
1011
0
            utf16_string,
1012
0
            utf16_string_size,
1013
0
            error );
1014
1015
0
  if( result == -1 )
1016
0
  {
1017
0
    libcerror_error_set(
1018
0
     error,
1019
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1020
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1021
0
     "%s: unable to copy identifier to UTF-16 string.",
1022
0
     function );
1023
1024
0
    return( -1 );
1025
0
  }
1026
0
  return( result );
1027
0
}
1028
1029
/* Retrieves the property type
1030
 * Returns 1 if successful or -1 on error
1031
 */
1032
int libewf_lef_permission_get_property_type(
1033
     libewf_lef_permission_t *lef_permission,
1034
     uint32_t *property_type,
1035
     libcerror_error_t **error )
1036
0
{
1037
0
  static char *function = "libewf_lef_permission_get_property_type";
1038
1039
0
  if( lef_permission == NULL )
1040
0
  {
1041
0
    libcerror_error_set(
1042
0
     error,
1043
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1044
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1045
0
     "%s: invalid permission.",
1046
0
     function );
1047
1048
0
    return( -1 );
1049
0
  }
1050
0
  if( property_type == NULL )
1051
0
  {
1052
0
    libcerror_error_set(
1053
0
     error,
1054
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1055
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1056
0
     "%s: invalid property type.",
1057
0
     function );
1058
1059
0
    return( -1 );
1060
0
  }
1061
0
  *property_type = lef_permission->property_type;
1062
1063
0
  return( 1 );
1064
0
}
1065
1066
/* Retrieves the access mask
1067
 * Returns 1 if successful or -1 on error
1068
 */
1069
int libewf_lef_permission_get_access_mask(
1070
     libewf_lef_permission_t *lef_permission,
1071
     uint32_t *access_mask,
1072
     libcerror_error_t **error )
1073
0
{
1074
0
  static char *function = "libewf_lef_permission_get_access_mask";
1075
1076
0
  if( lef_permission == NULL )
1077
0
  {
1078
0
    libcerror_error_set(
1079
0
     error,
1080
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1081
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1082
0
     "%s: invalid permission.",
1083
0
     function );
1084
1085
0
    return( -1 );
1086
0
  }
1087
0
  if( access_mask == NULL )
1088
0
  {
1089
0
    libcerror_error_set(
1090
0
     error,
1091
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1092
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1093
0
     "%s: invalid access mask.",
1094
0
     function );
1095
1096
0
    return( -1 );
1097
0
  }
1098
0
  *access_mask = lef_permission->access_mask;
1099
1100
0
  return( 1 );
1101
0
}
1102
1103
/* Retrieves the Windows NT access control entry (ACE) flags
1104
 * Returns 1 if successful or -1 on error
1105
 */
1106
int libewf_lef_permission_get_ace_flags(
1107
     libewf_lef_permission_t *lef_permission,
1108
     uint32_t *ace_flags,
1109
     libcerror_error_t **error )
1110
0
{
1111
0
  static char *function = "libewf_lef_permission_get_ace_flags";
1112
1113
0
  if( lef_permission == NULL )
1114
0
  {
1115
0
    libcerror_error_set(
1116
0
     error,
1117
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1118
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1119
0
     "%s: invalid permission.",
1120
0
     function );
1121
1122
0
    return( -1 );
1123
0
  }
1124
0
  if( ace_flags == NULL )
1125
0
  {
1126
0
    libcerror_error_set(
1127
0
     error,
1128
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1129
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1130
0
     "%s: invalid ACE flags.",
1131
0
     function );
1132
1133
0
    return( -1 );
1134
0
  }
1135
0
  *ace_flags = lef_permission->ace_flags;
1136
1137
0
  return( 1 );
1138
0
}
1139