Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libmsiecf/libmsiecf/libmsiecf_leak.c
Line
Count
Source
1
/*
2
 * Leak item functions
3
 *
4
 * Copyright (C) 2009-2026, Joachim Metz <joachim.metz@gmail.com>
5
 *
6
 * Refer to AUTHORS for acknowledgements.
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
#include <common.h>
23
#include <memory.h>
24
#include <types.h>
25
26
#include "libmsiecf_definitions.h"
27
#include "libmsiecf_item.h"
28
#include "libmsiecf_leak.h"
29
#include "libmsiecf_leak_values.h"
30
#include "libmsiecf_libcerror.h"
31
#include "libmsiecf_libfvalue.h"
32
33
/* Retrieves the cached file size
34
 * Returns 1 if successful or -1 on error
35
 */
36
int libmsiecf_leak_get_cached_file_size(
37
     libmsiecf_item_t *leak,
38
     uint64_t *cached_file_size,
39
     libcerror_error_t **error )
40
9.99k
{
41
9.99k
  libmsiecf_internal_item_t *internal_item = NULL;
42
9.99k
  static char *function                    = "libmsiecf_leak_get_cached_file_size";
43
44
9.99k
  if( leak == NULL )
45
0
  {
46
0
    libcerror_error_set(
47
0
     error,
48
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
49
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
50
0
     "%s: invalid leak.",
51
0
     function );
52
53
0
    return( -1 );
54
0
  }
55
9.99k
  internal_item = (libmsiecf_internal_item_t *) leak;
56
57
9.99k
  if( internal_item->item_descriptor == NULL )
58
0
  {
59
0
    libcerror_error_set(
60
0
     error,
61
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
62
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
63
0
     "%s: invalid item - missing item descriptor.",
64
0
     function );
65
66
0
    return( -1 );
67
0
  }
68
9.99k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
69
5.85k
  {
70
5.85k
    libcerror_error_set(
71
5.85k
     error,
72
5.85k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
73
5.85k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
74
5.85k
     "%s: unsupported item type: %" PRIu8 ".",
75
5.85k
     function,
76
5.85k
     internal_item->item_descriptor->type );
77
78
5.85k
    return( -1 );
79
5.85k
  }
80
4.13k
  if( internal_item->value == NULL )
81
0
  {
82
0
    libcerror_error_set(
83
0
     error,
84
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
85
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
86
0
     "%s: invalid item - missing item values.",
87
0
     function );
88
89
0
    return( -1 );
90
0
  }
91
4.13k
  if( cached_file_size == NULL )
92
2.06k
  {
93
2.06k
    libcerror_error_set(
94
2.06k
     error,
95
2.06k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
96
2.06k
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
97
2.06k
     "%s: invalid cached file size.",
98
2.06k
     function );
99
100
2.06k
    return( -1 );
101
2.06k
  }
102
2.06k
  *cached_file_size = (uint64_t) ( (libmsiecf_leak_values_t *) internal_item->value )->cached_file_size;
103
104
2.06k
  return( 1 );
105
4.13k
}
106
107
/* Retrieves the cache directory index
108
 * Returns 1 if successful or -1 on error
109
 */
110
int libmsiecf_leak_get_cache_directory_index(
111
     libmsiecf_item_t *leak,
112
     uint8_t *cache_directory_index,
113
     libcerror_error_t **error )
114
9.99k
{
115
9.99k
  libmsiecf_internal_item_t *internal_item = NULL;
116
9.99k
  static char *function                    = "libmsiecf_leak_get_cache_directory_index";
117
118
9.99k
  if( leak == NULL )
119
0
  {
120
0
    libcerror_error_set(
121
0
     error,
122
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
123
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
124
0
     "%s: invalid leak.",
125
0
     function );
126
127
0
    return( -1 );
128
0
  }
129
9.99k
  internal_item = (libmsiecf_internal_item_t *) leak;
130
131
9.99k
  if( internal_item->item_descriptor == NULL )
132
0
  {
133
0
    libcerror_error_set(
134
0
     error,
135
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
136
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
137
0
     "%s: invalid item - missing item descriptor.",
138
0
     function );
139
140
0
    return( -1 );
141
0
  }
142
9.99k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
143
5.85k
  {
144
5.85k
    libcerror_error_set(
145
5.85k
     error,
146
5.85k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
147
5.85k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
148
5.85k
     "%s: unsupported item type: %" PRIu8 ".",
149
5.85k
     function,
150
5.85k
     internal_item->item_descriptor->type );
151
152
5.85k
    return( -1 );
153
5.85k
  }
154
4.13k
  if( internal_item->value == NULL )
155
0
  {
156
0
    libcerror_error_set(
157
0
     error,
158
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
159
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
160
0
     "%s: invalid item - missing item values.",
161
0
     function );
162
163
0
    return( -1 );
164
0
  }
165
4.13k
  if( cache_directory_index == NULL )
166
2.06k
  {
167
2.06k
    libcerror_error_set(
168
2.06k
     error,
169
2.06k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
170
2.06k
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
171
2.06k
     "%s: invalid cache directory index.",
172
2.06k
     function );
173
174
2.06k
    return( -1 );
175
2.06k
  }
176
2.06k
  *cache_directory_index = ( (libmsiecf_leak_values_t *) internal_item->value )->cache_directory_index;
177
178
2.06k
  return( 1 );
179
4.13k
}
180
181
/* Retrieves the size of the filename
182
 * The returned size includes the end of string character
183
 * Returns 1 if successful, 0 if no filename or -1 on error
184
 */
185
int libmsiecf_leak_get_filename_size(
186
     libmsiecf_item_t *leak,
187
     size_t *string_size,
188
     libcerror_error_t **error )
189
9.99k
{
190
9.99k
  libmsiecf_internal_item_t *internal_item = NULL;
191
9.99k
  static char *function                    = "libmsiecf_leak_get_filename_size";
192
193
9.99k
  if( leak == NULL )
194
0
  {
195
0
    libcerror_error_set(
196
0
     error,
197
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
198
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
199
0
     "%s: invalid leak.",
200
0
     function );
201
202
0
    return( -1 );
203
0
  }
204
9.99k
  internal_item = (libmsiecf_internal_item_t *) leak;
205
206
9.99k
  if( internal_item->item_descriptor == NULL )
207
0
  {
208
0
    libcerror_error_set(
209
0
     error,
210
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
211
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
212
0
     "%s: invalid item - missing item descriptor.",
213
0
     function );
214
215
0
    return( -1 );
216
0
  }
217
9.99k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
218
5.85k
  {
219
5.85k
    libcerror_error_set(
220
5.85k
     error,
221
5.85k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
222
5.85k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
223
5.85k
     "%s: unsupported item type: %" PRIu8 ".",
224
5.85k
     function,
225
5.85k
     internal_item->item_descriptor->type );
226
227
5.85k
    return( -1 );
228
5.85k
  }
229
4.13k
  if( internal_item->value == NULL )
230
0
  {
231
0
    libcerror_error_set(
232
0
     error,
233
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
234
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
235
0
     "%s: invalid item - missing item values.",
236
0
     function );
237
238
0
    return( -1 );
239
0
  }
240
4.13k
  if( ( (libmsiecf_leak_values_t *) internal_item->value )->filename == NULL )
241
3.66k
  {
242
3.66k
    return( 0 );
243
3.66k
  }
244
468
  if( libfvalue_value_get_data_size(
245
468
       ( (libmsiecf_leak_values_t *) internal_item->value )->filename,
246
468
       string_size,
247
468
       error ) != 1 )
248
234
  {
249
234
    libcerror_error_set(
250
234
     error,
251
234
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
252
234
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
253
234
     "%s: unable to retrieve filename data size.",
254
234
     function );
255
256
234
    return( -1 );
257
234
  }
258
234
  return( 1 );
259
468
}
260
261
/* Retrieves the filename
262
 * The size should include the end of string character
263
 * Returns 1 if successful, 0 if no filename or -1 on error
264
 */
265
int libmsiecf_leak_get_filename(
266
     libmsiecf_item_t *leak,
267
     char *string,
268
     size_t string_size,
269
     libcerror_error_t **error )
270
14.9k
{
271
14.9k
  libmsiecf_internal_item_t *internal_item = NULL;
272
14.9k
  static char *function                    = "libmsiecf_leak_get_filename";
273
274
14.9k
  if( leak == NULL )
275
0
  {
276
0
    libcerror_error_set(
277
0
     error,
278
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
279
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
280
0
     "%s: invalid leak.",
281
0
     function );
282
283
0
    return( -1 );
284
0
  }
285
14.9k
  internal_item = (libmsiecf_internal_item_t *) leak;
286
287
14.9k
  if( internal_item->item_descriptor == NULL )
288
0
  {
289
0
    libcerror_error_set(
290
0
     error,
291
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
292
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
293
0
     "%s: invalid item - missing item descriptor.",
294
0
     function );
295
296
0
    return( -1 );
297
0
  }
298
14.9k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
299
8.78k
  {
300
8.78k
    libcerror_error_set(
301
8.78k
     error,
302
8.78k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
303
8.78k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
304
8.78k
     "%s: unsupported item type: %" PRIu8 ".",
305
8.78k
     function,
306
8.78k
     internal_item->item_descriptor->type );
307
308
8.78k
    return( -1 );
309
8.78k
  }
310
6.20k
  if( internal_item->value == NULL )
311
0
  {
312
0
    libcerror_error_set(
313
0
     error,
314
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
315
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
316
0
     "%s: invalid item - missing item values.",
317
0
     function );
318
319
0
    return( -1 );
320
0
  }
321
6.20k
  if( ( (libmsiecf_leak_values_t *) internal_item->value )->filename == NULL )
322
5.50k
  {
323
5.50k
    return( 0 );
324
5.50k
  }
325
702
  if( libfvalue_value_copy_data(
326
702
       ( (libmsiecf_leak_values_t *) internal_item->value )->filename,
327
702
       (uint8_t *) string,
328
702
       string_size,
329
702
       error ) != 1 )
330
383
  {
331
383
    libcerror_error_set(
332
383
     error,
333
383
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
334
383
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
335
383
     "%s: unable to copy filename data to string.",
336
383
     function );
337
338
383
    return( -1 );
339
383
  }
340
319
  return( 1 );
341
702
}
342
343
/* Retrieves the size of the UTF-8 encoded filename
344
 * The returned size includes the end of string character
345
 * Returns 1 if successful, 0 if no filename or -1 on error
346
 */
347
int libmsiecf_leak_get_utf8_filename_size(
348
     libmsiecf_item_t *leak,
349
     size_t *utf8_string_size,
350
     libcerror_error_t **error )
351
9.99k
{
352
9.99k
  libmsiecf_internal_item_t *internal_item = NULL;
353
9.99k
  static char *function                    = "libmsiecf_leak_get_utf8_filename_size";
354
355
9.99k
  if( leak == NULL )
356
0
  {
357
0
    libcerror_error_set(
358
0
     error,
359
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
360
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
361
0
     "%s: invalid leak.",
362
0
     function );
363
364
0
    return( -1 );
365
0
  }
366
9.99k
  internal_item = (libmsiecf_internal_item_t *) leak;
367
368
9.99k
  if( internal_item->item_descriptor == NULL )
369
0
  {
370
0
    libcerror_error_set(
371
0
     error,
372
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
373
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
374
0
     "%s: invalid item - missing item descriptor.",
375
0
     function );
376
377
0
    return( -1 );
378
0
  }
379
9.99k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
380
5.85k
  {
381
5.85k
    libcerror_error_set(
382
5.85k
     error,
383
5.85k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
384
5.85k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
385
5.85k
     "%s: unsupported item type: %" PRIu8 ".",
386
5.85k
     function,
387
5.85k
     internal_item->item_descriptor->type );
388
389
5.85k
    return( -1 );
390
5.85k
  }
391
4.13k
  if( internal_item->value == NULL )
392
0
  {
393
0
    libcerror_error_set(
394
0
     error,
395
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
396
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
397
0
     "%s: invalid item - missing item values.",
398
0
     function );
399
400
0
    return( -1 );
401
0
  }
402
4.13k
  if( ( (libmsiecf_leak_values_t *) internal_item->value )->filename == NULL )
403
3.66k
  {
404
3.66k
    return( 0 );
405
3.66k
  }
406
468
  if( libfvalue_value_get_utf8_string_size(
407
468
       ( (libmsiecf_leak_values_t *) internal_item->value )->filename,
408
468
       0,
409
468
       utf8_string_size,
410
468
       error ) != 1 )
411
256
  {
412
256
    libcerror_error_set(
413
256
     error,
414
256
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
415
256
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
416
256
     "%s: unable to retrieve UTF-8 filename string size.",
417
256
     function );
418
419
256
    return( -1 );
420
256
  }
421
212
  return( 1 );
422
468
}
423
424
/* Retrieves the UTF-8 encoded filename
425
 * The size should include the end of string character
426
 * Returns 1 if successful, 0 if no filename or -1 on error
427
 */
428
int libmsiecf_leak_get_utf8_filename(
429
     libmsiecf_item_t *leak,
430
     uint8_t *utf8_string,
431
     size_t utf8_string_size,
432
     libcerror_error_t **error )
433
14.9k
{
434
14.9k
  libmsiecf_internal_item_t *internal_item = NULL;
435
14.9k
  static char *function                    = "libmsiecf_leak_get_utf8_filename";
436
437
14.9k
  if( leak == NULL )
438
0
  {
439
0
    libcerror_error_set(
440
0
     error,
441
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
442
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
443
0
     "%s: invalid leak.",
444
0
     function );
445
446
0
    return( -1 );
447
0
  }
448
14.9k
  internal_item = (libmsiecf_internal_item_t *) leak;
449
450
14.9k
  if( internal_item->item_descriptor == NULL )
451
0
  {
452
0
    libcerror_error_set(
453
0
     error,
454
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
455
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
456
0
     "%s: invalid item - missing item descriptor.",
457
0
     function );
458
459
0
    return( -1 );
460
0
  }
461
14.9k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
462
8.78k
  {
463
8.78k
    libcerror_error_set(
464
8.78k
     error,
465
8.78k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
466
8.78k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
467
8.78k
     "%s: unsupported item type: %" PRIu8 ".",
468
8.78k
     function,
469
8.78k
     internal_item->item_descriptor->type );
470
471
8.78k
    return( -1 );
472
8.78k
  }
473
6.20k
  if( internal_item->value == NULL )
474
0
  {
475
0
    libcerror_error_set(
476
0
     error,
477
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
478
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
479
0
     "%s: invalid item - missing item values.",
480
0
     function );
481
482
0
    return( -1 );
483
0
  }
484
6.20k
  if( ( (libmsiecf_leak_values_t *) internal_item->value )->filename == NULL )
485
5.50k
  {
486
5.50k
    return( 0 );
487
5.50k
  }
488
702
  if( libfvalue_value_copy_to_utf8_string(
489
702
       ( (libmsiecf_leak_values_t *) internal_item->value )->filename,
490
702
       0,
491
702
       utf8_string,
492
702
       utf8_string_size,
493
702
       error ) != 1 )
494
383
  {
495
383
    libcerror_error_set(
496
383
     error,
497
383
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
498
383
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
499
383
     "%s: unable to copy filename to UTF-8 string.",
500
383
     function );
501
502
383
    return( -1 );
503
383
  }
504
319
  return( 1 );
505
702
}
506
507
/* Retrieves the size of the UTF-16 encoded filename
508
 * The returned size includes the end of string character
509
 * Returns 1 if successful, 0 if no filename or -1 on error
510
 */
511
int libmsiecf_leak_get_utf16_filename_size(
512
     libmsiecf_item_t *leak,
513
     size_t *utf16_string_size,
514
     libcerror_error_t **error )
515
9.99k
{
516
9.99k
  libmsiecf_internal_item_t *internal_item = NULL;
517
9.99k
  static char *function                    = "libmsiecf_leak_get_utf16_filename_size";
518
519
9.99k
  if( leak == NULL )
520
0
  {
521
0
    libcerror_error_set(
522
0
     error,
523
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
524
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
525
0
     "%s: invalid leak.",
526
0
     function );
527
528
0
    return( -1 );
529
0
  }
530
9.99k
  internal_item = (libmsiecf_internal_item_t *) leak;
531
532
9.99k
  if( internal_item->item_descriptor == NULL )
533
0
  {
534
0
    libcerror_error_set(
535
0
     error,
536
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
537
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
538
0
     "%s: invalid item - missing item descriptor.",
539
0
     function );
540
541
0
    return( -1 );
542
0
  }
543
9.99k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
544
5.85k
  {
545
5.85k
    libcerror_error_set(
546
5.85k
     error,
547
5.85k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
548
5.85k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
549
5.85k
     "%s: unsupported item type: %" PRIu8 ".",
550
5.85k
     function,
551
5.85k
     internal_item->item_descriptor->type );
552
553
5.85k
    return( -1 );
554
5.85k
  }
555
4.13k
  if( internal_item->value == NULL )
556
0
  {
557
0
    libcerror_error_set(
558
0
     error,
559
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
560
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
561
0
     "%s: invalid item - missing item values.",
562
0
     function );
563
564
0
    return( -1 );
565
0
  }
566
4.13k
  if( ( (libmsiecf_leak_values_t *) internal_item->value )->filename == NULL )
567
3.66k
  {
568
3.66k
    return( 0 );
569
3.66k
  }
570
468
  if( libfvalue_value_get_utf16_string_size(
571
468
       ( (libmsiecf_leak_values_t *) internal_item->value )->filename,
572
468
       0,
573
468
       utf16_string_size,
574
468
       error ) != 1 )
575
256
  {
576
256
    libcerror_error_set(
577
256
     error,
578
256
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
579
256
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
580
256
     "%s: unable to retrieve UTF-16 filename string size.",
581
256
     function );
582
583
256
    return( -1 );
584
256
  }
585
212
  return( 1 );
586
468
}
587
588
/* Retrieves the UTF-16 encoded filename
589
 * The size should include the end of string character
590
 * Returns 1 if successful, 0 if no filename or -1 on error
591
 */
592
int libmsiecf_leak_get_utf16_filename(
593
     libmsiecf_item_t *leak,
594
     uint16_t *utf16_string,
595
     size_t utf16_string_size,
596
     libcerror_error_t **error )
597
14.9k
{
598
14.9k
  libmsiecf_internal_item_t *internal_item = NULL;
599
14.9k
  static char *function                    = "libmsiecf_leak_get_utf16_filename";
600
601
14.9k
  if( leak == NULL )
602
0
  {
603
0
    libcerror_error_set(
604
0
     error,
605
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
606
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
607
0
     "%s: invalid leak.",
608
0
     function );
609
610
0
    return( -1 );
611
0
  }
612
14.9k
  internal_item = (libmsiecf_internal_item_t *) leak;
613
614
14.9k
  if( internal_item->item_descriptor == NULL )
615
0
  {
616
0
    libcerror_error_set(
617
0
     error,
618
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
619
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
620
0
     "%s: invalid item - missing item descriptor.",
621
0
     function );
622
623
0
    return( -1 );
624
0
  }
625
14.9k
  if( internal_item->item_descriptor->type != LIBMSIECF_ITEM_TYPE_LEAK )
626
8.78k
  {
627
8.78k
    libcerror_error_set(
628
8.78k
     error,
629
8.78k
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
630
8.78k
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
631
8.78k
     "%s: unsupported item type: %" PRIu8 ".",
632
8.78k
     function,
633
8.78k
     internal_item->item_descriptor->type );
634
635
8.78k
    return( -1 );
636
8.78k
  }
637
6.20k
  if( internal_item->value == NULL )
638
0
  {
639
0
    libcerror_error_set(
640
0
     error,
641
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
642
0
     LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
643
0
     "%s: invalid item - missing item values.",
644
0
     function );
645
646
0
    return( -1 );
647
0
  }
648
6.20k
  if( ( (libmsiecf_leak_values_t *) internal_item->value )->filename == NULL )
649
5.50k
  {
650
5.50k
    return( 0 );
651
5.50k
  }
652
702
  if( libfvalue_value_copy_to_utf16_string(
653
702
       ( (libmsiecf_leak_values_t *) internal_item->value )->filename,
654
702
       0,
655
702
       utf16_string,
656
702
       utf16_string_size,
657
702
       error ) != 1 )
658
383
  {
659
383
    libcerror_error_set(
660
383
     error,
661
383
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
662
383
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
663
383
     "%s: unable to copy filename to UTF-16 string.",
664
383
     function );
665
666
383
    return( -1 );
667
383
  }
668
319
  return( 1 );
669
702
}
670