/src/libewf/libewf/libewf_lef_file_entry.c
Line | Count | Source |
1 | | /* |
2 | | * Logical Evidence File (LEF) file entry 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_debug.h" |
27 | | #include "libewf_definitions.h" |
28 | | #include "libewf_lef_extended_attribute.h" |
29 | | #include "libewf_lef_file_entry.h" |
30 | | #include "libewf_libcdata.h" |
31 | | #include "libewf_libcerror.h" |
32 | | #include "libewf_libcnotify.h" |
33 | | #include "libewf_libfguid.h" |
34 | | #include "libewf_libfvalue.h" |
35 | | #include "libewf_libuna.h" |
36 | | #include "libewf_serialized_string.h" |
37 | | #include "libewf_value_reader.h" |
38 | | |
39 | | const uint8_t libewf_lef_extended_attributes_header[ 37 ] = { |
40 | | 0x00, 0x00, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x41, 0x00, 0x74, |
41 | | 0x00, 0x74, 0x00, 0x72, 0x00, 0x69, 0x00, 0x62, 0x00, 0x75, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, |
42 | | 0x00, 0x00, 0x00, 0x00, 0x00 }; |
43 | | |
44 | | /* Creates a file entry |
45 | | * Make sure the value lef_file_entry is referencing, is set to NULL |
46 | | * Returns 1 if successful or -1 on error |
47 | | */ |
48 | | int libewf_lef_file_entry_initialize( |
49 | | libewf_lef_file_entry_t **lef_file_entry, |
50 | | libcerror_error_t **error ) |
51 | 0 | { |
52 | 0 | static char *function = "libewf_lef_file_entry_initialize"; |
53 | |
|
54 | 0 | if( lef_file_entry == 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 file entry.", |
61 | 0 | function ); |
62 | |
|
63 | 0 | return( -1 ); |
64 | 0 | } |
65 | 0 | if( *lef_file_entry != 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 file entry value already set.", |
72 | 0 | function ); |
73 | |
|
74 | 0 | return( -1 ); |
75 | 0 | } |
76 | 0 | *lef_file_entry = memory_allocate_structure( |
77 | 0 | libewf_lef_file_entry_t ); |
78 | |
|
79 | 0 | if( *lef_file_entry == NULL ) |
80 | 0 | { |
81 | 0 | libcerror_error_set( |
82 | 0 | error, |
83 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
84 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
85 | 0 | "%s: unable to create file entry.", |
86 | 0 | function ); |
87 | |
|
88 | 0 | goto on_error; |
89 | 0 | } |
90 | 0 | if( memory_set( |
91 | 0 | *lef_file_entry, |
92 | 0 | 0, |
93 | 0 | sizeof( libewf_lef_file_entry_t ) ) == NULL ) |
94 | 0 | { |
95 | 0 | libcerror_error_set( |
96 | 0 | error, |
97 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
98 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
99 | 0 | "%s: unable to clear file entry.", |
100 | 0 | function ); |
101 | |
|
102 | 0 | memory_free( |
103 | 0 | *lef_file_entry ); |
104 | |
|
105 | 0 | *lef_file_entry = NULL; |
106 | |
|
107 | 0 | return( -1 ); |
108 | 0 | } |
109 | 0 | if( libewf_serialized_string_initialize( |
110 | 0 | &( ( *lef_file_entry )->guid ), |
111 | 0 | error ) != 1 ) |
112 | 0 | { |
113 | 0 | libcerror_error_set( |
114 | 0 | error, |
115 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
116 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
117 | 0 | "%s: unable to create GUID string.", |
118 | 0 | function ); |
119 | |
|
120 | 0 | goto on_error; |
121 | 0 | } |
122 | 0 | if( libewf_serialized_string_initialize( |
123 | 0 | &( ( *lef_file_entry )->short_name ), |
124 | 0 | error ) != 1 ) |
125 | 0 | { |
126 | 0 | libcerror_error_set( |
127 | 0 | error, |
128 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
129 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
130 | 0 | "%s: unable to create short name string.", |
131 | 0 | function ); |
132 | |
|
133 | 0 | goto on_error; |
134 | 0 | } |
135 | 0 | if( libewf_serialized_string_initialize( |
136 | 0 | &( ( *lef_file_entry )->md5_hash ), |
137 | 0 | error ) != 1 ) |
138 | 0 | { |
139 | 0 | libcerror_error_set( |
140 | 0 | error, |
141 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
142 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
143 | 0 | "%s: unable to create MD5 hash string.", |
144 | 0 | function ); |
145 | |
|
146 | 0 | goto on_error; |
147 | 0 | } |
148 | 0 | if( libewf_serialized_string_initialize( |
149 | 0 | &( ( *lef_file_entry )->sha1_hash ), |
150 | 0 | error ) != 1 ) |
151 | 0 | { |
152 | 0 | libcerror_error_set( |
153 | 0 | error, |
154 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
155 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
156 | 0 | "%s: unable to create SHA1 hash string.", |
157 | 0 | function ); |
158 | |
|
159 | 0 | goto on_error; |
160 | 0 | } |
161 | 0 | if( libcdata_array_initialize( |
162 | 0 | &( ( *lef_file_entry )->extended_attributes ), |
163 | 0 | 0, |
164 | 0 | error ) != 1 ) |
165 | 0 | { |
166 | 0 | libcerror_error_set( |
167 | 0 | error, |
168 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
169 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
170 | 0 | "%s: unable to create extended attributes array.", |
171 | 0 | function ); |
172 | |
|
173 | 0 | goto on_error; |
174 | 0 | } |
175 | 0 | ( *lef_file_entry )->data_offset = -1; |
176 | 0 | ( *lef_file_entry )->duplicate_data_offset = -1; |
177 | 0 | ( *lef_file_entry )->permission_group_index = 0; |
178 | |
|
179 | 0 | return( 1 ); |
180 | | |
181 | 0 | on_error: |
182 | 0 | if( *lef_file_entry != NULL ) |
183 | 0 | { |
184 | 0 | if( ( *lef_file_entry )->sha1_hash != NULL ) |
185 | 0 | { |
186 | 0 | libewf_serialized_string_free( |
187 | 0 | &( ( *lef_file_entry )->sha1_hash ), |
188 | 0 | NULL ); |
189 | 0 | } |
190 | 0 | if( ( *lef_file_entry )->md5_hash != NULL ) |
191 | 0 | { |
192 | 0 | libewf_serialized_string_free( |
193 | 0 | &( ( *lef_file_entry )->md5_hash ), |
194 | 0 | NULL ); |
195 | 0 | } |
196 | 0 | if( ( *lef_file_entry )->short_name != NULL ) |
197 | 0 | { |
198 | 0 | libewf_serialized_string_free( |
199 | 0 | &( ( *lef_file_entry )->short_name ), |
200 | 0 | NULL ); |
201 | 0 | } |
202 | 0 | if( ( *lef_file_entry )->guid != NULL ) |
203 | 0 | { |
204 | 0 | libewf_serialized_string_free( |
205 | 0 | &( ( *lef_file_entry )->guid ), |
206 | 0 | NULL ); |
207 | 0 | } |
208 | 0 | memory_free( |
209 | 0 | *lef_file_entry ); |
210 | |
|
211 | 0 | *lef_file_entry = NULL; |
212 | 0 | } |
213 | 0 | return( -1 ); |
214 | 0 | } |
215 | | |
216 | | /* Frees a file entry |
217 | | * Returns 1 if successful or -1 on error |
218 | | */ |
219 | | int libewf_lef_file_entry_free( |
220 | | libewf_lef_file_entry_t **lef_file_entry, |
221 | | libcerror_error_t **error ) |
222 | 0 | { |
223 | 0 | static char *function = "libewf_lef_file_entry_free"; |
224 | 0 | int result = 1; |
225 | |
|
226 | 0 | if( lef_file_entry == NULL ) |
227 | 0 | { |
228 | 0 | libcerror_error_set( |
229 | 0 | error, |
230 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
231 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
232 | 0 | "%s: invalid file entry.", |
233 | 0 | function ); |
234 | |
|
235 | 0 | return( -1 ); |
236 | 0 | } |
237 | 0 | if( *lef_file_entry != NULL ) |
238 | 0 | { |
239 | 0 | if( ( *lef_file_entry )->guid != NULL ) |
240 | 0 | { |
241 | 0 | if( libewf_serialized_string_free( |
242 | 0 | &( ( *lef_file_entry )->guid ), |
243 | 0 | error ) != 1 ) |
244 | 0 | { |
245 | 0 | libcerror_error_set( |
246 | 0 | error, |
247 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
248 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
249 | 0 | "%s: unable to free GUID string.", |
250 | 0 | function ); |
251 | |
|
252 | 0 | result = -1; |
253 | 0 | } |
254 | 0 | } |
255 | 0 | if( ( *lef_file_entry )->name_data != NULL ) |
256 | 0 | { |
257 | 0 | memory_free( |
258 | 0 | ( *lef_file_entry )->name_data ); |
259 | 0 | } |
260 | 0 | if( ( *lef_file_entry )->short_name != NULL ) |
261 | 0 | { |
262 | 0 | if( libewf_serialized_string_free( |
263 | 0 | &( ( *lef_file_entry )->short_name ), |
264 | 0 | error ) != 1 ) |
265 | 0 | { |
266 | 0 | libcerror_error_set( |
267 | 0 | error, |
268 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
269 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
270 | 0 | "%s: unable to free short name string.", |
271 | 0 | function ); |
272 | |
|
273 | 0 | result = -1; |
274 | 0 | } |
275 | 0 | } |
276 | 0 | if( ( *lef_file_entry )->md5_hash != NULL ) |
277 | 0 | { |
278 | 0 | if( libewf_serialized_string_free( |
279 | 0 | &( ( *lef_file_entry )->md5_hash ), |
280 | 0 | error ) != 1 ) |
281 | 0 | { |
282 | 0 | libcerror_error_set( |
283 | 0 | error, |
284 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
285 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
286 | 0 | "%s: unable to free MD5 hash string.", |
287 | 0 | function ); |
288 | |
|
289 | 0 | result = -1; |
290 | 0 | } |
291 | 0 | } |
292 | 0 | if( ( *lef_file_entry )->sha1_hash != NULL ) |
293 | 0 | { |
294 | 0 | if( libewf_serialized_string_free( |
295 | 0 | &( ( *lef_file_entry )->sha1_hash ), |
296 | 0 | error ) != 1 ) |
297 | 0 | { |
298 | 0 | libcerror_error_set( |
299 | 0 | error, |
300 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
301 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
302 | 0 | "%s: unable to free SHA1 hash string.", |
303 | 0 | function ); |
304 | |
|
305 | 0 | result = -1; |
306 | 0 | } |
307 | 0 | } |
308 | 0 | if( ( *lef_file_entry )->extended_attributes != NULL ) |
309 | 0 | { |
310 | 0 | if( libcdata_array_free( |
311 | 0 | &( ( *lef_file_entry )->extended_attributes ), |
312 | 0 | (int (*)(intptr_t **, libcerror_error_t **)) &libewf_lef_extended_attribute_free, |
313 | 0 | error ) != 1 ) |
314 | 0 | { |
315 | 0 | libcerror_error_set( |
316 | 0 | error, |
317 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
318 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
319 | 0 | "%s: unable to free extended attributes array.", |
320 | 0 | function ); |
321 | |
|
322 | 0 | result = -1; |
323 | 0 | } |
324 | 0 | } |
325 | 0 | memory_free( |
326 | 0 | *lef_file_entry ); |
327 | |
|
328 | 0 | *lef_file_entry = NULL; |
329 | 0 | } |
330 | 0 | return( result ); |
331 | 0 | } |
332 | | |
333 | | /* Clones the file entry |
334 | | * Returns 1 if successful or -1 on error |
335 | | */ |
336 | | int libewf_lef_file_entry_clone( |
337 | | libewf_lef_file_entry_t **destination_lef_file_entry, |
338 | | libewf_lef_file_entry_t *source_lef_file_entry, |
339 | | libcerror_error_t **error ) |
340 | 0 | { |
341 | 0 | static char *function = "libewf_lef_file_entry_clone"; |
342 | |
|
343 | 0 | if( destination_lef_file_entry == NULL ) |
344 | 0 | { |
345 | 0 | libcerror_error_set( |
346 | 0 | error, |
347 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
348 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
349 | 0 | "%s: invalid destination file entry.", |
350 | 0 | function ); |
351 | |
|
352 | 0 | return( -1 ); |
353 | 0 | } |
354 | 0 | if( *destination_lef_file_entry != NULL ) |
355 | 0 | { |
356 | 0 | libcerror_error_set( |
357 | 0 | error, |
358 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
359 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
360 | 0 | "%s: invalid destination file entry value already set.", |
361 | 0 | function ); |
362 | |
|
363 | 0 | return( -1 ); |
364 | 0 | } |
365 | 0 | if( source_lef_file_entry == NULL ) |
366 | 0 | { |
367 | 0 | *destination_lef_file_entry = NULL; |
368 | |
|
369 | 0 | return( 1 ); |
370 | 0 | } |
371 | 0 | *destination_lef_file_entry = memory_allocate_structure( |
372 | 0 | libewf_lef_file_entry_t ); |
373 | |
|
374 | 0 | if( *destination_lef_file_entry == NULL ) |
375 | 0 | { |
376 | 0 | libcerror_error_set( |
377 | 0 | error, |
378 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
379 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
380 | 0 | "%s: unable to create destination file entry.", |
381 | 0 | function ); |
382 | |
|
383 | 0 | goto on_error; |
384 | 0 | } |
385 | 0 | if( memory_copy( |
386 | 0 | *destination_lef_file_entry, |
387 | 0 | source_lef_file_entry, |
388 | 0 | sizeof( libewf_lef_file_entry_t ) ) == NULL ) |
389 | 0 | { |
390 | 0 | libcerror_error_set( |
391 | 0 | error, |
392 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
393 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
394 | 0 | "%s: unable to copy source to destination file entry.", |
395 | 0 | function ); |
396 | |
|
397 | 0 | memory_free( |
398 | 0 | *destination_lef_file_entry ); |
399 | |
|
400 | 0 | *destination_lef_file_entry = NULL; |
401 | |
|
402 | 0 | return( -1 ); |
403 | 0 | } |
404 | 0 | ( *destination_lef_file_entry )->guid = NULL; |
405 | 0 | ( *destination_lef_file_entry )->name_data = NULL; |
406 | 0 | ( *destination_lef_file_entry )->short_name = NULL; |
407 | 0 | ( *destination_lef_file_entry )->md5_hash = NULL; |
408 | 0 | ( *destination_lef_file_entry )->sha1_hash = NULL; |
409 | 0 | ( *destination_lef_file_entry )->extended_attributes = NULL; |
410 | |
|
411 | 0 | if( libewf_serialized_string_clone( |
412 | 0 | &( ( *destination_lef_file_entry )->guid ), |
413 | 0 | source_lef_file_entry->guid, |
414 | 0 | error ) != 1 ) |
415 | 0 | { |
416 | 0 | libcerror_error_set( |
417 | 0 | error, |
418 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
419 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
420 | 0 | "%s: unable to clone destination GUID string.", |
421 | 0 | function ); |
422 | |
|
423 | 0 | goto on_error; |
424 | 0 | } |
425 | 0 | ( *destination_lef_file_entry )->name_data = (uint8_t *) memory_allocate( |
426 | 0 | source_lef_file_entry->name_data_size ); |
427 | |
|
428 | 0 | if( ( *destination_lef_file_entry )->name_data == NULL ) |
429 | 0 | { |
430 | 0 | libcerror_error_set( |
431 | 0 | error, |
432 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
433 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
434 | 0 | "%s: unable to create destination name data.", |
435 | 0 | function ); |
436 | |
|
437 | 0 | goto on_error; |
438 | 0 | } |
439 | 0 | if( memory_copy( |
440 | 0 | ( *destination_lef_file_entry )->name_data, |
441 | 0 | source_lef_file_entry->name_data, |
442 | 0 | source_lef_file_entry->name_data_size ) == NULL ) |
443 | 0 | { |
444 | 0 | libcerror_error_set( |
445 | 0 | error, |
446 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
447 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
448 | 0 | "%s: unable to copy source to destination name data.", |
449 | 0 | function ); |
450 | |
|
451 | 0 | goto on_error; |
452 | 0 | } |
453 | 0 | if( libewf_serialized_string_clone( |
454 | 0 | &( ( *destination_lef_file_entry )->short_name ), |
455 | 0 | source_lef_file_entry->short_name, |
456 | 0 | error ) != 1 ) |
457 | 0 | { |
458 | 0 | libcerror_error_set( |
459 | 0 | error, |
460 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
461 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
462 | 0 | "%s: unable to clone destination short name string.", |
463 | 0 | function ); |
464 | |
|
465 | 0 | goto on_error; |
466 | 0 | } |
467 | 0 | if( libewf_serialized_string_clone( |
468 | 0 | &( ( *destination_lef_file_entry )->md5_hash ), |
469 | 0 | source_lef_file_entry->md5_hash, |
470 | 0 | error ) != 1 ) |
471 | 0 | { |
472 | 0 | libcerror_error_set( |
473 | 0 | error, |
474 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
475 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
476 | 0 | "%s: unable to clone destination MD5 hash string.", |
477 | 0 | function ); |
478 | |
|
479 | 0 | goto on_error; |
480 | 0 | } |
481 | 0 | if( libewf_serialized_string_clone( |
482 | 0 | &( ( *destination_lef_file_entry )->sha1_hash ), |
483 | 0 | source_lef_file_entry->sha1_hash, |
484 | 0 | error ) != 1 ) |
485 | 0 | { |
486 | 0 | libcerror_error_set( |
487 | 0 | error, |
488 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
489 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
490 | 0 | "%s: unable to clone destination SHA1 hash string.", |
491 | 0 | function ); |
492 | |
|
493 | 0 | goto on_error; |
494 | 0 | } |
495 | 0 | if( libcdata_array_clone( |
496 | 0 | &( ( *destination_lef_file_entry )->extended_attributes ), |
497 | 0 | source_lef_file_entry->extended_attributes, |
498 | 0 | (int (*)(intptr_t **, libcerror_error_t **)) &libewf_lef_extended_attribute_free, |
499 | 0 | (int (*)(intptr_t **, intptr_t *, libcerror_error_t **)) &libewf_lef_extended_attribute_clone, |
500 | 0 | error ) != 1 ) |
501 | 0 | { |
502 | 0 | libcerror_error_set( |
503 | 0 | error, |
504 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
505 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
506 | 0 | "%s: unable to create destination extended attributes array.", |
507 | 0 | function ); |
508 | |
|
509 | 0 | goto on_error; |
510 | 0 | } |
511 | 0 | return( 1 ); |
512 | | |
513 | 0 | on_error: |
514 | 0 | if( *destination_lef_file_entry != NULL ) |
515 | 0 | { |
516 | 0 | libewf_lef_file_entry_free( |
517 | 0 | destination_lef_file_entry, |
518 | 0 | NULL ); |
519 | 0 | } |
520 | 0 | return( -1 ); |
521 | 0 | } |
522 | | |
523 | | /* Reads a single file binary extents |
524 | | * Returns 1 if successful or -1 on error |
525 | | */ |
526 | | int libewf_lef_file_entry_read_binary_extents( |
527 | | libewf_lef_file_entry_t *lef_file_entry, |
528 | | const uint8_t *data, |
529 | | size_t data_size, |
530 | | libcerror_error_t **error ) |
531 | 0 | { |
532 | 0 | libfvalue_split_utf8_string_t *values = NULL; |
533 | 0 | uint8_t *value_string = NULL; |
534 | 0 | static char *function = "libewf_lef_file_entry_read_binary_extents"; |
535 | 0 | size_t value_string_size = 0; |
536 | 0 | uint64_t value_64bit = 0; |
537 | 0 | int number_of_values = 0; |
538 | |
|
539 | 0 | if( lef_file_entry == NULL ) |
540 | 0 | { |
541 | 0 | libcerror_error_set( |
542 | 0 | error, |
543 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
544 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
545 | 0 | "%s: invalid file entry.", |
546 | 0 | function ); |
547 | |
|
548 | 0 | return( -1 ); |
549 | 0 | } |
550 | 0 | if( libfvalue_utf8_string_split( |
551 | 0 | data, |
552 | 0 | data_size, |
553 | 0 | (uint8_t) ' ', |
554 | 0 | &values, |
555 | 0 | error ) != 1 ) |
556 | 0 | { |
557 | 0 | libcerror_error_set( |
558 | 0 | error, |
559 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
560 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
561 | 0 | "%s: unable to split string into values.", |
562 | 0 | function ); |
563 | |
|
564 | 0 | goto on_error; |
565 | 0 | } |
566 | 0 | if( libfvalue_split_utf8_string_get_number_of_segments( |
567 | 0 | values, |
568 | 0 | &number_of_values, |
569 | 0 | error ) != 1 ) |
570 | 0 | { |
571 | 0 | libcerror_error_set( |
572 | 0 | error, |
573 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
574 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
575 | 0 | "%s: unable to retrieve number of values", |
576 | 0 | function ); |
577 | |
|
578 | 0 | goto on_error; |
579 | 0 | } |
580 | 0 | if( ( number_of_values != 1 ) |
581 | 0 | && ( number_of_values != 3 ) ) |
582 | 0 | { |
583 | 0 | libcerror_error_set( |
584 | 0 | error, |
585 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
586 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
587 | 0 | "%s: unsupported number of values.", |
588 | 0 | function ); |
589 | |
|
590 | 0 | goto on_error; |
591 | 0 | } |
592 | 0 | if( number_of_values == 3 ) |
593 | 0 | { |
594 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
595 | 0 | values, |
596 | 0 | 1, |
597 | 0 | &value_string, |
598 | 0 | &value_string_size, |
599 | 0 | error ) != 1 ) |
600 | 0 | { |
601 | 0 | libcerror_error_set( |
602 | 0 | error, |
603 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
604 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
605 | 0 | "%s: unable to retrieve value string: 1.", |
606 | 0 | function ); |
607 | |
|
608 | 0 | goto on_error; |
609 | 0 | } |
610 | 0 | if( libfvalue_utf8_string_copy_to_integer( |
611 | 0 | value_string, |
612 | 0 | value_string_size, |
613 | 0 | &value_64bit, |
614 | 0 | 64, |
615 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_HEXADECIMAL | LIBFVALUE_INTEGER_FORMAT_FLAG_NO_BASE_INDICATOR, |
616 | 0 | error ) != 1 ) |
617 | 0 | { |
618 | 0 | libcerror_error_set( |
619 | 0 | error, |
620 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
621 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
622 | 0 | "%s: unable to set data offset.", |
623 | 0 | function ); |
624 | |
|
625 | 0 | goto on_error; |
626 | 0 | } |
627 | 0 | lef_file_entry->data_offset = (off64_t) value_64bit; |
628 | |
|
629 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
630 | 0 | values, |
631 | 0 | 2, |
632 | 0 | &value_string, |
633 | 0 | &value_string_size, |
634 | 0 | error ) != 1 ) |
635 | 0 | { |
636 | 0 | libcerror_error_set( |
637 | 0 | error, |
638 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
639 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
640 | 0 | "%s: unable to retrieve value string: 2.", |
641 | 0 | function ); |
642 | |
|
643 | 0 | goto on_error; |
644 | 0 | } |
645 | 0 | if( libfvalue_utf8_string_copy_to_integer( |
646 | 0 | value_string, |
647 | 0 | value_string_size, |
648 | 0 | &value_64bit, |
649 | 0 | 64, |
650 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_HEXADECIMAL | LIBFVALUE_INTEGER_FORMAT_FLAG_NO_BASE_INDICATOR, |
651 | 0 | error ) != 1 ) |
652 | 0 | { |
653 | 0 | libcerror_error_set( |
654 | 0 | error, |
655 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
656 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
657 | 0 | "%s: unable to set data size.", |
658 | 0 | function ); |
659 | |
|
660 | 0 | goto on_error; |
661 | 0 | } |
662 | 0 | lef_file_entry->data_size = (size64_t) value_64bit; |
663 | |
|
664 | | #if defined( HAVE_DEBUG_OUTPUT ) |
665 | | if( libcnotify_verbose != 0 ) |
666 | | { |
667 | | libcnotify_printf( |
668 | | "%s: data offset\t\t\t: %" PRIi64 " (0x%08" PRIx64 ")\n", |
669 | | function, |
670 | | lef_file_entry->data_offset, |
671 | | lef_file_entry->data_offset ); |
672 | | |
673 | | libcnotify_printf( |
674 | | "%s: data size\t\t\t: %" PRIu64 "\n", |
675 | | function, |
676 | | lef_file_entry->size ); |
677 | | |
678 | | libcnotify_printf( |
679 | | "\n" ); |
680 | | } |
681 | | #endif |
682 | 0 | } |
683 | 0 | if( libfvalue_split_utf8_string_free( |
684 | 0 | &values, |
685 | 0 | error ) != 1 ) |
686 | 0 | { |
687 | 0 | libcerror_error_set( |
688 | 0 | error, |
689 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
690 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
691 | 0 | "%s: unable to free split values.", |
692 | 0 | function ); |
693 | |
|
694 | 0 | goto on_error; |
695 | 0 | } |
696 | 0 | return( 1 ); |
697 | | |
698 | 0 | on_error: |
699 | 0 | if( values != NULL ) |
700 | 0 | { |
701 | 0 | libfvalue_split_utf8_string_free( |
702 | 0 | &values, |
703 | 0 | NULL ); |
704 | 0 | } |
705 | 0 | return( -1 ); |
706 | 0 | } |
707 | | |
708 | | /* Reads a single file extended attributes |
709 | | * Returns 1 if successful or -1 on error |
710 | | */ |
711 | | int libewf_lef_file_entry_read_extended_attributes( |
712 | | libewf_lef_file_entry_t *lef_file_entry, |
713 | | const uint8_t *data, |
714 | | size_t data_size, |
715 | | libcerror_error_t **error ) |
716 | 0 | { |
717 | 0 | libewf_lef_extended_attribute_t *lef_extended_attribute = NULL; |
718 | 0 | static char *function = "libewf_lef_file_entry_read_extended_attributes"; |
719 | 0 | size_t data_offset = 0; |
720 | 0 | ssize_t read_count = 0; |
721 | 0 | int entry_index = 0; |
722 | |
|
723 | 0 | if( lef_file_entry == NULL ) |
724 | 0 | { |
725 | 0 | libcerror_error_set( |
726 | 0 | error, |
727 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
728 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
729 | 0 | "%s: invalid file entry.", |
730 | 0 | function ); |
731 | |
|
732 | 0 | return( -1 ); |
733 | 0 | } |
734 | 0 | if( data == NULL ) |
735 | 0 | { |
736 | 0 | libcerror_error_set( |
737 | 0 | error, |
738 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
739 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
740 | 0 | "%s: invalid data.", |
741 | 0 | function ); |
742 | |
|
743 | 0 | return( -1 ); |
744 | 0 | } |
745 | 0 | if( ( data_size < 37 ) |
746 | 0 | || ( data_size > (size_t) SSIZE_MAX ) ) |
747 | 0 | { |
748 | 0 | libcerror_error_set( |
749 | 0 | error, |
750 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
751 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, |
752 | 0 | "%s: invalid data size value out of bounds.", |
753 | 0 | function ); |
754 | |
|
755 | 0 | return( -1 ); |
756 | 0 | } |
757 | | #if defined( HAVE_DEBUG_OUTPUT ) |
758 | | if( libcnotify_verbose != 0 ) |
759 | | { |
760 | | libcnotify_printf( |
761 | | "%s: extended attributes data:\n", |
762 | | function ); |
763 | | libcnotify_print_data( |
764 | | data, |
765 | | data_size, |
766 | | 0 ); |
767 | | } |
768 | | #endif |
769 | 0 | if( memory_compare( |
770 | 0 | libewf_lef_extended_attributes_header, |
771 | 0 | data, |
772 | 0 | 37 ) != 0 ) |
773 | 0 | { |
774 | 0 | libcerror_error_set( |
775 | 0 | error, |
776 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
777 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
778 | 0 | "%s: unsupported extended attributes header.", |
779 | 0 | function ); |
780 | |
|
781 | 0 | goto on_error; |
782 | 0 | } |
783 | 0 | while( data_offset < data_size ) |
784 | 0 | { |
785 | 0 | if( libewf_lef_extended_attribute_initialize( |
786 | 0 | &lef_extended_attribute, |
787 | 0 | error ) != 1 ) |
788 | 0 | { |
789 | 0 | libcerror_error_set( |
790 | 0 | error, |
791 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
792 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
793 | 0 | "%s: unable to create extended attribute.", |
794 | 0 | function ); |
795 | |
|
796 | 0 | goto on_error; |
797 | 0 | } |
798 | 0 | read_count = libewf_lef_extended_attribute_read_data( |
799 | 0 | lef_extended_attribute, |
800 | 0 | &( data[ data_offset ] ), |
801 | 0 | data_size - data_offset, |
802 | 0 | error ); |
803 | |
|
804 | 0 | if( read_count == -1 ) |
805 | 0 | { |
806 | 0 | libcerror_error_set( |
807 | 0 | error, |
808 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
809 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
810 | 0 | "%s: unable to read extended attribute.", |
811 | 0 | function ); |
812 | |
|
813 | 0 | goto on_error; |
814 | 0 | } |
815 | 0 | data_offset += read_count; |
816 | |
|
817 | 0 | if( lef_extended_attribute->is_branch == 0 ) |
818 | 0 | { |
819 | 0 | if( libcdata_array_append_entry( |
820 | 0 | lef_file_entry->extended_attributes, |
821 | 0 | &entry_index, |
822 | 0 | (intptr_t *) lef_extended_attribute, |
823 | 0 | error ) != 1 ) |
824 | 0 | { |
825 | 0 | libcerror_error_set( |
826 | 0 | error, |
827 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
828 | 0 | LIBCERROR_RUNTIME_ERROR_APPEND_FAILED, |
829 | 0 | "%s: unable to append entry to extended attributes array.", |
830 | 0 | function ); |
831 | |
|
832 | 0 | goto on_error; |
833 | 0 | } |
834 | 0 | lef_extended_attribute = NULL; |
835 | 0 | } |
836 | 0 | else |
837 | 0 | { |
838 | 0 | if( libewf_lef_extended_attribute_free( |
839 | 0 | &lef_extended_attribute, |
840 | 0 | error ) != 1 ) |
841 | 0 | { |
842 | 0 | libcerror_error_set( |
843 | 0 | error, |
844 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
845 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
846 | 0 | "%s: unable to free extended attribute.", |
847 | 0 | function ); |
848 | |
|
849 | 0 | goto on_error; |
850 | 0 | } |
851 | 0 | } |
852 | 0 | } |
853 | 0 | return( 1 ); |
854 | | |
855 | 0 | on_error: |
856 | 0 | if( lef_extended_attribute != NULL ) |
857 | 0 | { |
858 | 0 | libewf_lef_extended_attribute_free( |
859 | 0 | &lef_extended_attribute, |
860 | 0 | NULL ); |
861 | 0 | } |
862 | 0 | return( -1 ); |
863 | 0 | } |
864 | | |
865 | | /* Reads a file entry short name |
866 | | * Returns 1 if successful or -1 on error |
867 | | */ |
868 | | int libewf_lef_file_entry_read_short_name( |
869 | | libewf_lef_file_entry_t *lef_file_entry, |
870 | | const uint8_t *data, |
871 | | size_t data_size, |
872 | | libcerror_error_t **error ) |
873 | 0 | { |
874 | 0 | libfvalue_split_utf8_string_t *values = NULL; |
875 | 0 | uint8_t *value_string = NULL; |
876 | 0 | static char *function = "libewf_lef_file_entry_read_short_name"; |
877 | 0 | size_t value_string_size = 0; |
878 | 0 | uint64_t short_name_size = 0; |
879 | 0 | int number_of_values = 0; |
880 | |
|
881 | 0 | if( lef_file_entry == NULL ) |
882 | 0 | { |
883 | 0 | libcerror_error_set( |
884 | 0 | error, |
885 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
886 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
887 | 0 | "%s: invalid file entry.", |
888 | 0 | function ); |
889 | |
|
890 | 0 | return( -1 ); |
891 | 0 | } |
892 | 0 | if( libfvalue_utf8_string_split( |
893 | 0 | data, |
894 | 0 | data_size, |
895 | 0 | (uint8_t) ' ', |
896 | 0 | &values, |
897 | 0 | error ) != 1 ) |
898 | 0 | { |
899 | 0 | libcerror_error_set( |
900 | 0 | error, |
901 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
902 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
903 | 0 | "%s: unable to split string into values.", |
904 | 0 | function ); |
905 | |
|
906 | 0 | goto on_error; |
907 | 0 | } |
908 | 0 | if( libfvalue_split_utf8_string_get_number_of_segments( |
909 | 0 | values, |
910 | 0 | &number_of_values, |
911 | 0 | error ) != 1 ) |
912 | 0 | { |
913 | 0 | libcerror_error_set( |
914 | 0 | error, |
915 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
916 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
917 | 0 | "%s: unable to retrieve number of values", |
918 | 0 | function ); |
919 | |
|
920 | 0 | goto on_error; |
921 | 0 | } |
922 | 0 | if( number_of_values != 2 ) |
923 | 0 | { |
924 | 0 | libcerror_error_set( |
925 | 0 | error, |
926 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
927 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
928 | 0 | "%s: unsupported number of values.", |
929 | 0 | function ); |
930 | |
|
931 | 0 | goto on_error; |
932 | 0 | } |
933 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
934 | 0 | values, |
935 | 0 | 0, |
936 | 0 | &value_string, |
937 | 0 | &value_string_size, |
938 | 0 | error ) != 1 ) |
939 | 0 | { |
940 | 0 | libcerror_error_set( |
941 | 0 | error, |
942 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
943 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
944 | 0 | "%s: unable to retrieve value string: 0.", |
945 | 0 | function ); |
946 | |
|
947 | 0 | goto on_error; |
948 | 0 | } |
949 | 0 | if( libfvalue_utf8_string_copy_to_integer( |
950 | 0 | value_string, |
951 | 0 | value_string_size, |
952 | 0 | &short_name_size, |
953 | 0 | 64, |
954 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
955 | 0 | error ) != 1 ) |
956 | 0 | { |
957 | 0 | libcerror_error_set( |
958 | 0 | error, |
959 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
960 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
961 | 0 | "%s: unable to set short name size.", |
962 | 0 | function ); |
963 | |
|
964 | 0 | goto on_error; |
965 | 0 | } |
966 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
967 | 0 | values, |
968 | 0 | 1, |
969 | 0 | &value_string, |
970 | 0 | &value_string_size, |
971 | 0 | error ) != 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 value string: 1.", |
978 | 0 | function ); |
979 | |
|
980 | 0 | goto on_error; |
981 | 0 | } |
982 | 0 | if( ( short_name_size > (uint64_t) SSIZE_MAX ) |
983 | 0 | || ( (size_t) short_name_size != value_string_size ) ) |
984 | 0 | { |
985 | 0 | libcerror_error_set( |
986 | 0 | error, |
987 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
988 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
989 | 0 | "%s: invalid short name size value out of bounds.", |
990 | 0 | function ); |
991 | |
|
992 | 0 | goto on_error; |
993 | 0 | } |
994 | 0 | if( ( value_string != NULL ) |
995 | 0 | && ( value_string_size > 0 ) ) |
996 | 0 | { |
997 | 0 | if( libewf_serialized_string_read_data( |
998 | 0 | lef_file_entry->short_name, |
999 | 0 | value_string, |
1000 | 0 | value_string_size - 1, |
1001 | 0 | LIBEWF_VALUE_DATA_TYPE_UTF8, |
1002 | 0 | error ) != 1 ) |
1003 | 0 | { |
1004 | 0 | libcerror_error_set( |
1005 | 0 | error, |
1006 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1007 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1008 | 0 | "%s: unable to read short name string.", |
1009 | 0 | function ); |
1010 | |
|
1011 | 0 | goto on_error; |
1012 | 0 | } |
1013 | 0 | } |
1014 | 0 | if( libfvalue_split_utf8_string_free( |
1015 | 0 | &values, |
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_FINALIZE_FAILED, |
1022 | 0 | "%s: unable to free split values.", |
1023 | 0 | function ); |
1024 | |
|
1025 | 0 | goto on_error; |
1026 | 0 | } |
1027 | 0 | return( 1 ); |
1028 | | |
1029 | 0 | on_error: |
1030 | 0 | if( values != NULL ) |
1031 | 0 | { |
1032 | 0 | libfvalue_split_utf8_string_free( |
1033 | 0 | &values, |
1034 | 0 | NULL ); |
1035 | 0 | } |
1036 | 0 | return( -1 ); |
1037 | 0 | } |
1038 | | |
1039 | | /* Reads a file entry |
1040 | | * Returns 1 if successful or -1 on error |
1041 | | */ |
1042 | | int libewf_lef_file_entry_read_data( |
1043 | | libewf_lef_file_entry_t *lef_file_entry, |
1044 | | libfvalue_split_utf8_string_t *types, |
1045 | | const uint8_t *data, |
1046 | | size_t data_size, |
1047 | | libcerror_error_t **error ) |
1048 | 0 | { |
1049 | 0 | libewf_value_reader_t *value_reader = NULL; |
1050 | 0 | uint8_t *byte_stream = NULL; |
1051 | 0 | uint8_t *type_string = NULL; |
1052 | 0 | uint8_t *utf8_string = NULL; |
1053 | 0 | const uint8_t *value_data = NULL; |
1054 | 0 | static char *function = "libewf_lef_file_entry_read_data"; |
1055 | 0 | size_t byte_stream_size = 0; |
1056 | 0 | size_t type_string_size = 0; |
1057 | 0 | size_t utf8_string_size = 0; |
1058 | 0 | size_t value_data_size = 0; |
1059 | 0 | uint64_t value_64bit_unsigned = 0; |
1060 | 0 | int64_t value_64bit_signed = 0; |
1061 | 0 | int known_value = 0; |
1062 | 0 | int number_of_types = 0; |
1063 | 0 | int result = 0; |
1064 | 0 | int value_index = 0; |
1065 | |
|
1066 | 0 | if( lef_file_entry == NULL ) |
1067 | 0 | { |
1068 | 0 | libcerror_error_set( |
1069 | 0 | error, |
1070 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1071 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1072 | 0 | "%s: invalid file entry.", |
1073 | 0 | function ); |
1074 | |
|
1075 | 0 | return( -1 ); |
1076 | 0 | } |
1077 | 0 | if( lef_file_entry->name_data != NULL ) |
1078 | 0 | { |
1079 | 0 | libcerror_error_set( |
1080 | 0 | error, |
1081 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1082 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
1083 | 0 | "%s: invalid file entry - name data value already set.", |
1084 | 0 | function ); |
1085 | |
|
1086 | 0 | return( -1 ); |
1087 | 0 | } |
1088 | 0 | if( libfvalue_split_utf8_string_get_number_of_segments( |
1089 | 0 | types, |
1090 | 0 | &number_of_types, |
1091 | 0 | error ) != 1 ) |
1092 | 0 | { |
1093 | 0 | libcerror_error_set( |
1094 | 0 | error, |
1095 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1096 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1097 | 0 | "%s: unable to retrieve number of types", |
1098 | 0 | function ); |
1099 | |
|
1100 | 0 | goto on_error; |
1101 | 0 | } |
1102 | 0 | if( libewf_value_reader_initialize( |
1103 | 0 | &value_reader, |
1104 | 0 | error ) != 1 ) |
1105 | 0 | { |
1106 | 0 | libcerror_error_set( |
1107 | 0 | error, |
1108 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1109 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
1110 | 0 | "%s: unable to create value reader.", |
1111 | 0 | function ); |
1112 | |
|
1113 | 0 | goto on_error; |
1114 | 0 | } |
1115 | 0 | if( libewf_value_reader_set_buffer( |
1116 | 0 | value_reader, |
1117 | 0 | 0, |
1118 | 0 | data, |
1119 | 0 | data_size, |
1120 | 0 | LIBEWF_VALUE_DATA_TYPE_UTF16, |
1121 | 0 | error ) != 1 ) |
1122 | 0 | { |
1123 | 0 | libcerror_error_set( |
1124 | 0 | error, |
1125 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1126 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1127 | 0 | "%s: unable to set buffer in value reader.", |
1128 | 0 | function ); |
1129 | |
|
1130 | 0 | goto on_error; |
1131 | 0 | } |
1132 | 0 | for( value_index = 0; |
1133 | 0 | value_index < number_of_types; |
1134 | 0 | value_index++ ) |
1135 | 0 | { |
1136 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
1137 | 0 | types, |
1138 | 0 | value_index, |
1139 | 0 | &type_string, |
1140 | 0 | &type_string_size, |
1141 | 0 | error ) != 1 ) |
1142 | 0 | { |
1143 | 0 | libcerror_error_set( |
1144 | 0 | error, |
1145 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1146 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1147 | 0 | "%s: unable to retrieve type string: %d.", |
1148 | 0 | function, |
1149 | 0 | value_index ); |
1150 | |
|
1151 | 0 | goto on_error; |
1152 | 0 | } |
1153 | 0 | if( ( type_string == NULL ) |
1154 | 0 | || ( type_string_size < 2 ) |
1155 | 0 | || ( type_string[ 0 ] == 0 ) ) |
1156 | 0 | { |
1157 | 0 | libcerror_error_set( |
1158 | 0 | error, |
1159 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1160 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
1161 | 0 | "%s: missing type string: %d.", |
1162 | 0 | function, |
1163 | 0 | value_index ); |
1164 | |
|
1165 | 0 | goto on_error; |
1166 | 0 | } |
1167 | 0 | known_value = 0; |
1168 | |
|
1169 | 0 | if( type_string_size == 4 ) |
1170 | 0 | { |
1171 | 0 | if( ( type_string[ 0 ] == (uint8_t) 'c' ) |
1172 | 0 | && ( type_string[ 1 ] == (uint8_t) 'i' ) |
1173 | 0 | && ( type_string[ 2 ] == (uint8_t) 'd' ) ) |
1174 | 0 | { |
1175 | 0 | result = libewf_value_reader_read_integer_unsigned( |
1176 | 0 | value_reader, |
1177 | 0 | &value_64bit_unsigned, |
1178 | 0 | error ); |
1179 | |
|
1180 | 0 | if( result == -1 ) |
1181 | 0 | { |
1182 | 0 | libcerror_error_set( |
1183 | 0 | error, |
1184 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1185 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1186 | 0 | "%s: unable to read record type value.", |
1187 | 0 | function ); |
1188 | |
|
1189 | 0 | goto on_error; |
1190 | 0 | } |
1191 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1192 | | if( libcnotify_verbose != 0 ) |
1193 | | { |
1194 | | libcnotify_printf( |
1195 | | "%s: type: %3s with value\t\t\t:", |
1196 | | function, |
1197 | | (char *) type_string ); |
1198 | | |
1199 | | if( result != 0 ) |
1200 | | { |
1201 | | libcnotify_printf( |
1202 | | " %" PRIu64 "", |
1203 | | value_64bit_unsigned ); |
1204 | | } |
1205 | | libcnotify_printf( |
1206 | | "\n" ); |
1207 | | } |
1208 | | #endif |
1209 | 0 | if( result != 0 ) |
1210 | 0 | { |
1211 | 0 | if( value_64bit_unsigned > (uint64_t) UINT32_MAX ) |
1212 | 0 | { |
1213 | 0 | libcerror_error_set( |
1214 | 0 | error, |
1215 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1216 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
1217 | 0 | "%s: invalid record type value out of bounds.", |
1218 | 0 | function ); |
1219 | |
|
1220 | 0 | goto on_error; |
1221 | 0 | } |
1222 | 0 | lef_file_entry->record_type = (uint32_t) value_64bit_unsigned; |
1223 | 0 | } |
1224 | 0 | known_value = 1; |
1225 | 0 | } |
1226 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'm' ) |
1227 | 0 | && ( type_string[ 1 ] == (uint8_t) 'i' ) |
1228 | 0 | && ( type_string[ 2 ] == (uint8_t) 'd' ) ) |
1229 | 0 | { |
1230 | 0 | result = libewf_value_reader_read_serialized_string_base16( |
1231 | 0 | value_reader, |
1232 | 0 | lef_file_entry->guid, |
1233 | 0 | error ); |
1234 | |
|
1235 | 0 | if( result == -1 ) |
1236 | 0 | { |
1237 | 0 | libcerror_error_set( |
1238 | 0 | error, |
1239 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1240 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1241 | 0 | "%s: unable to read GUID value.", |
1242 | 0 | function ); |
1243 | |
|
1244 | 0 | goto on_error; |
1245 | 0 | } |
1246 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1247 | | if( libcnotify_verbose != 0 ) |
1248 | | { |
1249 | | libcnotify_printf( |
1250 | | "%s: type: %3s with value:\n", |
1251 | | function, |
1252 | | (char *) type_string ); |
1253 | | libcnotify_print_data( |
1254 | | lef_file_entry->guid->data, |
1255 | | lef_file_entry->guid->data_size, |
1256 | | 0 ); |
1257 | | } |
1258 | | #endif |
1259 | 0 | known_value = 1; |
1260 | 0 | } |
1261 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'o' ) |
1262 | 0 | && ( type_string[ 1 ] == (uint8_t) 'p' ) |
1263 | 0 | && ( type_string[ 2 ] == (uint8_t) 'r' ) ) |
1264 | 0 | { |
1265 | 0 | result = libewf_value_reader_read_integer_unsigned( |
1266 | 0 | value_reader, |
1267 | 0 | &value_64bit_unsigned, |
1268 | 0 | error ); |
1269 | |
|
1270 | 0 | if( result == -1 ) |
1271 | 0 | { |
1272 | 0 | libcerror_error_set( |
1273 | 0 | error, |
1274 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1275 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1276 | 0 | "%s: unable to read entry flags value.", |
1277 | 0 | function ); |
1278 | |
|
1279 | 0 | goto on_error; |
1280 | 0 | } |
1281 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1282 | | if( libcnotify_verbose != 0 ) |
1283 | | { |
1284 | | libcnotify_printf( |
1285 | | "%s: type: %3s with value\t\t\t:", |
1286 | | function, |
1287 | | (char *) type_string ); |
1288 | | |
1289 | | if( result != 0 ) |
1290 | | { |
1291 | | libcnotify_printf( |
1292 | | " %" PRIu64 "", |
1293 | | value_64bit_unsigned ); |
1294 | | } |
1295 | | libcnotify_printf( |
1296 | | "\n" ); |
1297 | | } |
1298 | | #endif |
1299 | 0 | if( result != 0 ) |
1300 | 0 | { |
1301 | 0 | if( value_64bit_unsigned > (uint64_t) UINT32_MAX ) |
1302 | 0 | { |
1303 | 0 | libcerror_error_set( |
1304 | 0 | error, |
1305 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1306 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
1307 | 0 | "%s: invalid entry flags value out of bounds.", |
1308 | 0 | function ); |
1309 | |
|
1310 | 0 | goto on_error; |
1311 | 0 | } |
1312 | 0 | lef_file_entry->flags = (uint32_t) value_64bit_unsigned; |
1313 | 0 | } |
1314 | 0 | known_value = 1; |
1315 | 0 | } |
1316 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 's' ) |
1317 | 0 | && ( type_string[ 1 ] == (uint8_t) 'r' ) |
1318 | 0 | && ( type_string[ 2 ] == (uint8_t) 'c' ) ) |
1319 | 0 | { |
1320 | 0 | result = libewf_value_reader_read_integer_unsigned( |
1321 | 0 | value_reader, |
1322 | 0 | &value_64bit_unsigned, |
1323 | 0 | error ); |
1324 | |
|
1325 | 0 | if( result == -1 ) |
1326 | 0 | { |
1327 | 0 | libcerror_error_set( |
1328 | 0 | error, |
1329 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1330 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1331 | 0 | "%s: unable to read source identifier value.", |
1332 | 0 | function ); |
1333 | |
|
1334 | 0 | goto on_error; |
1335 | 0 | } |
1336 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1337 | | if( libcnotify_verbose != 0 ) |
1338 | | { |
1339 | | libcnotify_printf( |
1340 | | "%s: type: %3s with value\t\t\t:", |
1341 | | function, |
1342 | | (char *) type_string ); |
1343 | | |
1344 | | if( result != 0 ) |
1345 | | { |
1346 | | libcnotify_printf( |
1347 | | " %" PRIu64 "", |
1348 | | value_64bit_unsigned ); |
1349 | | } |
1350 | | libcnotify_printf( |
1351 | | "\n" ); |
1352 | | } |
1353 | | #endif |
1354 | 0 | if( result != 0 ) |
1355 | 0 | { |
1356 | 0 | if( ( (int64_t) value_64bit_unsigned < (int64_t) 0 ) |
1357 | 0 | || ( (int64_t) value_64bit_unsigned > (int64_t) INT_MAX ) ) |
1358 | 0 | { |
1359 | 0 | libcerror_error_set( |
1360 | 0 | error, |
1361 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1362 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
1363 | 0 | "%s: invalid source identifier value out of bounds.", |
1364 | 0 | function ); |
1365 | |
|
1366 | 0 | goto on_error; |
1367 | 0 | } |
1368 | 0 | lef_file_entry->source_identifier = (int) value_64bit_unsigned; |
1369 | 0 | } |
1370 | 0 | known_value = 1; |
1371 | 0 | } |
1372 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 's' ) |
1373 | 0 | && ( type_string[ 1 ] == (uint8_t) 'u' ) |
1374 | 0 | && ( type_string[ 2 ] == (uint8_t) 'b' ) ) |
1375 | 0 | { |
1376 | 0 | result = libewf_value_reader_read_integer_signed( |
1377 | 0 | value_reader, |
1378 | 0 | &value_64bit_signed, |
1379 | 0 | error ); |
1380 | |
|
1381 | 0 | if( result == -1 ) |
1382 | 0 | { |
1383 | 0 | libcerror_error_set( |
1384 | 0 | error, |
1385 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1386 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1387 | 0 | "%s: unable to read subject identifier value.", |
1388 | 0 | function ); |
1389 | |
|
1390 | 0 | goto on_error; |
1391 | 0 | } |
1392 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1393 | | if( libcnotify_verbose != 0 ) |
1394 | | { |
1395 | | libcnotify_printf( |
1396 | | "%s: type: %3s with value\t\t\t:", |
1397 | | function, |
1398 | | (char *) type_string ); |
1399 | | |
1400 | | if( result != 0 ) |
1401 | | { |
1402 | | libcnotify_printf( |
1403 | | " %" PRIi64 "", |
1404 | | value_64bit_signed ); |
1405 | | } |
1406 | | libcnotify_printf( |
1407 | | "\n" ); |
1408 | | } |
1409 | | #endif |
1410 | 0 | if( result != 0 ) |
1411 | 0 | { |
1412 | 0 | if( value_64bit_signed > (int64_t) UINT32_MAX ) |
1413 | 0 | { |
1414 | 0 | libcerror_error_set( |
1415 | 0 | error, |
1416 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1417 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
1418 | 0 | "%s: invalid subject identifier value out of bounds.", |
1419 | 0 | function ); |
1420 | |
|
1421 | 0 | goto on_error; |
1422 | 0 | } |
1423 | 0 | lef_file_entry->subject_identifier = (uint32_t) value_64bit_signed; |
1424 | 0 | } |
1425 | 0 | known_value = 1; |
1426 | 0 | } |
1427 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 's' ) |
1428 | 0 | && ( type_string[ 1 ] == (uint8_t) 'h' ) |
1429 | 0 | && ( type_string[ 2 ] == (uint8_t) 'a' ) ) |
1430 | 0 | { |
1431 | 0 | result = libewf_value_reader_read_serialized_string_base16( |
1432 | 0 | value_reader, |
1433 | 0 | lef_file_entry->sha1_hash, |
1434 | 0 | error ); |
1435 | |
|
1436 | 0 | if( result == -1 ) |
1437 | 0 | { |
1438 | 0 | libcerror_error_set( |
1439 | 0 | error, |
1440 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1441 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1442 | 0 | "%s: unable to read SHA1 hash value.", |
1443 | 0 | function ); |
1444 | |
|
1445 | 0 | goto on_error; |
1446 | 0 | } |
1447 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1448 | | if( libcnotify_verbose != 0 ) |
1449 | | { |
1450 | | libcnotify_printf( |
1451 | | "%s: type: %3s with value:\n", |
1452 | | function, |
1453 | | (char *) type_string ); |
1454 | | libcnotify_print_data( |
1455 | | lef_file_entry->sha1_hash->data, |
1456 | | lef_file_entry->sha1_hash->data_size, |
1457 | | 0 ); |
1458 | | } |
1459 | | #endif |
1460 | 0 | known_value = 1; |
1461 | 0 | } |
1462 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 's' ) |
1463 | 0 | && ( type_string[ 1 ] == (uint8_t) 'n' ) |
1464 | 0 | && ( type_string[ 2 ] == (uint8_t) 'h' ) ) |
1465 | 0 | { |
1466 | 0 | if( libewf_value_reader_read_utf8_string( |
1467 | 0 | value_reader, |
1468 | 0 | &utf8_string, |
1469 | 0 | &utf8_string_size, |
1470 | 0 | error ) != 1 ) |
1471 | 0 | { |
1472 | 0 | libcerror_error_set( |
1473 | 0 | error, |
1474 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1475 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1476 | 0 | "%s: unable to read read short name value data.", |
1477 | 0 | function ); |
1478 | |
|
1479 | 0 | goto on_error; |
1480 | 0 | } |
1481 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1482 | | if( libcnotify_verbose != 0 ) |
1483 | | { |
1484 | | libcnotify_printf( |
1485 | | "%s: type: %3s with value:\n", |
1486 | | function, |
1487 | | (char *) type_string ); |
1488 | | libcnotify_print_data( |
1489 | | utf8_string, |
1490 | | utf8_string_size, |
1491 | | 0 ); |
1492 | | } |
1493 | | #endif |
1494 | 0 | if( ( utf8_string != NULL ) |
1495 | 0 | && ( utf8_string_size > 0 ) ) |
1496 | 0 | { |
1497 | | /* Note that libfvalue_utf8_string_split expects the value string size including the end-of-string character */ |
1498 | 0 | if( libewf_lef_file_entry_read_short_name( |
1499 | 0 | lef_file_entry, |
1500 | 0 | utf8_string, |
1501 | 0 | utf8_string_size, |
1502 | 0 | error ) != 1 ) |
1503 | 0 | { |
1504 | 0 | libcerror_error_set( |
1505 | 0 | error, |
1506 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1507 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1508 | 0 | "%s: unable to read short name.", |
1509 | 0 | function ); |
1510 | |
|
1511 | 0 | goto on_error; |
1512 | 0 | } |
1513 | 0 | } |
1514 | 0 | known_value = 1; |
1515 | 0 | } |
1516 | 0 | } |
1517 | 0 | else if( type_string_size == 3 ) |
1518 | 0 | { |
1519 | | /* Access time |
1520 | | */ |
1521 | 0 | if( ( type_string[ 0 ] == (uint8_t) 'a' ) |
1522 | 0 | && ( type_string[ 1 ] == (uint8_t) 'c' ) ) |
1523 | 0 | { |
1524 | 0 | result = libewf_value_reader_read_integer_signed( |
1525 | 0 | value_reader, |
1526 | 0 | &( lef_file_entry->access_time ), |
1527 | 0 | error ); |
1528 | |
|
1529 | 0 | if( result == -1 ) |
1530 | 0 | { |
1531 | 0 | libcerror_error_set( |
1532 | 0 | error, |
1533 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1534 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1535 | 0 | "%s: unable to read access time value.", |
1536 | 0 | function ); |
1537 | |
|
1538 | 0 | goto on_error; |
1539 | 0 | } |
1540 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1541 | | if( libcnotify_verbose != 0 ) |
1542 | | { |
1543 | | libcnotify_printf( |
1544 | | "%s: type: %3s with value\t\t\t:", |
1545 | | function, |
1546 | | (char *) type_string ); |
1547 | | |
1548 | | if( result != 0 ) |
1549 | | { |
1550 | | libcnotify_printf( |
1551 | | " %" PRIi64 "", |
1552 | | lef_file_entry->access_time ); |
1553 | | } |
1554 | | libcnotify_printf( |
1555 | | "\n" ); |
1556 | | } |
1557 | | #endif |
1558 | 0 | known_value = 1; |
1559 | 0 | } |
1560 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'a' ) |
1561 | 0 | && ( type_string[ 1 ] == (uint8_t) 'q' ) ) |
1562 | 0 | { |
1563 | | /* TODO implement */ |
1564 | 0 | } |
1565 | | /* Data offset |
1566 | | * consist of: unknown, offset and size |
1567 | | */ |
1568 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'b' ) |
1569 | 0 | && ( type_string[ 1 ] == (uint8_t) 'e' ) ) |
1570 | 0 | { |
1571 | 0 | if( libewf_value_reader_read_utf8_string( |
1572 | 0 | value_reader, |
1573 | 0 | &utf8_string, |
1574 | 0 | &utf8_string_size, |
1575 | 0 | error ) != 1 ) |
1576 | 0 | { |
1577 | 0 | libcerror_error_set( |
1578 | 0 | error, |
1579 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1580 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1581 | 0 | "%s: unable to read read binary extents value data.", |
1582 | 0 | function ); |
1583 | |
|
1584 | 0 | goto on_error; |
1585 | 0 | } |
1586 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1587 | | if( libcnotify_verbose != 0 ) |
1588 | | { |
1589 | | libcnotify_printf( |
1590 | | "%s: type: %3s with value:\n", |
1591 | | function, |
1592 | | (char *) type_string ); |
1593 | | libcnotify_print_data( |
1594 | | utf8_string, |
1595 | | utf8_string_size, |
1596 | | 0 ); |
1597 | | } |
1598 | | #endif |
1599 | 0 | if( ( utf8_string != NULL ) |
1600 | 0 | && ( utf8_string_size > 0 ) ) |
1601 | 0 | { |
1602 | | /* Note that libfvalue_utf8_string_split expects the value string size including the end-of-string character */ |
1603 | 0 | if( libewf_lef_file_entry_read_binary_extents( |
1604 | 0 | lef_file_entry, |
1605 | 0 | utf8_string, |
1606 | 0 | utf8_string_size, |
1607 | 0 | error ) != 1 ) |
1608 | 0 | { |
1609 | 0 | libcerror_error_set( |
1610 | 0 | error, |
1611 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1612 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1613 | 0 | "%s: unable to read binary extents.", |
1614 | 0 | function ); |
1615 | |
|
1616 | 0 | goto on_error; |
1617 | 0 | } |
1618 | 0 | } |
1619 | 0 | known_value = 1; |
1620 | 0 | } |
1621 | | /* Creation time |
1622 | | */ |
1623 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'c' ) |
1624 | 0 | && ( type_string[ 1 ] == (uint8_t) 'r' ) ) |
1625 | 0 | { |
1626 | 0 | result = libewf_value_reader_read_integer_signed( |
1627 | 0 | value_reader, |
1628 | 0 | &( lef_file_entry->creation_time ), |
1629 | 0 | error ); |
1630 | |
|
1631 | 0 | if( result == -1 ) |
1632 | 0 | { |
1633 | 0 | libcerror_error_set( |
1634 | 0 | error, |
1635 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1636 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1637 | 0 | "%s: unable to read creation time value.", |
1638 | 0 | function ); |
1639 | |
|
1640 | 0 | goto on_error; |
1641 | 0 | } |
1642 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1643 | | if( libcnotify_verbose != 0 ) |
1644 | | { |
1645 | | libcnotify_printf( |
1646 | | "%s: type: %3s with value\t\t\t:", |
1647 | | function, |
1648 | | (char *) type_string ); |
1649 | | |
1650 | | if( result != 0 ) |
1651 | | { |
1652 | | libcnotify_printf( |
1653 | | " %" PRIi64 "", |
1654 | | lef_file_entry->creation_time ); |
1655 | | } |
1656 | | libcnotify_printf( |
1657 | | "\n" ); |
1658 | | } |
1659 | | #endif |
1660 | 0 | known_value = 1; |
1661 | 0 | } |
1662 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'd' ) |
1663 | 0 | && ( type_string[ 1 ] == (uint8_t) 'l' ) ) |
1664 | 0 | { |
1665 | 0 | result = libewf_value_reader_read_integer_signed( |
1666 | 0 | value_reader, |
1667 | 0 | &( lef_file_entry->deletion_time ), |
1668 | 0 | error ); |
1669 | |
|
1670 | 0 | if( result == -1 ) |
1671 | 0 | { |
1672 | 0 | libcerror_error_set( |
1673 | 0 | error, |
1674 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1675 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1676 | 0 | "%s: unable to read deletion time value.", |
1677 | 0 | function ); |
1678 | |
|
1679 | 0 | goto on_error; |
1680 | 0 | } |
1681 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1682 | | if( libcnotify_verbose != 0 ) |
1683 | | { |
1684 | | libcnotify_printf( |
1685 | | "%s: type: %3s with value\t\t\t:", |
1686 | | function, |
1687 | | (char *) type_string ); |
1688 | | |
1689 | | if( result != 0 ) |
1690 | | { |
1691 | | libcnotify_printf( |
1692 | | " %" PRIi64 "", |
1693 | | lef_file_entry->deletion_time ); |
1694 | | } |
1695 | | libcnotify_printf( |
1696 | | "\n" ); |
1697 | | } |
1698 | | #endif |
1699 | 0 | known_value = 1; |
1700 | 0 | } |
1701 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'd' ) |
1702 | 0 | && ( type_string[ 1 ] == (uint8_t) 'u' ) ) |
1703 | 0 | { |
1704 | 0 | result = libewf_value_reader_read_integer_signed( |
1705 | 0 | value_reader, |
1706 | 0 | &( lef_file_entry->duplicate_data_offset ), |
1707 | 0 | error ); |
1708 | |
|
1709 | 0 | if( result == -1 ) |
1710 | 0 | { |
1711 | 0 | libcerror_error_set( |
1712 | 0 | error, |
1713 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1714 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1715 | 0 | "%s: unable to read duplicate data offset value.", |
1716 | 0 | function ); |
1717 | |
|
1718 | 0 | goto on_error; |
1719 | 0 | } |
1720 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1721 | | if( libcnotify_verbose != 0 ) |
1722 | | { |
1723 | | libcnotify_printf( |
1724 | | "%s: type: %3s with value\t\t\t:", |
1725 | | function, |
1726 | | (char *) type_string ); |
1727 | | |
1728 | | if( result != 0 ) |
1729 | | { |
1730 | | libcnotify_printf( |
1731 | | " %" PRIi64 "", |
1732 | | lef_file_entry->duplicate_data_offset ); |
1733 | | } |
1734 | | libcnotify_printf( |
1735 | | "\n" ); |
1736 | | } |
1737 | | #endif |
1738 | 0 | known_value = 1; |
1739 | 0 | } |
1740 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'e' ) |
1741 | 0 | && ( type_string[ 1 ] == (uint8_t) 'a' ) ) |
1742 | 0 | { |
1743 | 0 | if( libewf_value_reader_read_byte_stream_base16( |
1744 | 0 | value_reader, |
1745 | 0 | &byte_stream, |
1746 | 0 | &byte_stream_size, |
1747 | 0 | error ) != 1 ) |
1748 | 0 | { |
1749 | 0 | libcerror_error_set( |
1750 | 0 | error, |
1751 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1752 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1753 | 0 | "%s: unable to read read extended attributes value data.", |
1754 | 0 | function ); |
1755 | |
|
1756 | 0 | goto on_error; |
1757 | 0 | } |
1758 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1759 | | if( libcnotify_verbose != 0 ) |
1760 | | { |
1761 | | libcnotify_printf( |
1762 | | "%s: type: %3s with value:\n", |
1763 | | function, |
1764 | | (char *) type_string ); |
1765 | | libcnotify_print_data( |
1766 | | byte_stream, |
1767 | | byte_stream_size, |
1768 | | 0 ); |
1769 | | } |
1770 | | #endif |
1771 | 0 | if( ( byte_stream != NULL ) |
1772 | 0 | && ( byte_stream_size > 0 ) ) |
1773 | 0 | { |
1774 | 0 | if( libewf_lef_file_entry_read_extended_attributes( |
1775 | 0 | lef_file_entry, |
1776 | 0 | byte_stream, |
1777 | 0 | byte_stream_size, |
1778 | 0 | error ) != 1 ) |
1779 | 0 | { |
1780 | 0 | libcerror_error_set( |
1781 | 0 | error, |
1782 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1783 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1784 | 0 | "%s: unable to read extended attributes.", |
1785 | 0 | function ); |
1786 | |
|
1787 | 0 | goto on_error; |
1788 | 0 | } |
1789 | 0 | } |
1790 | 0 | known_value = 1; |
1791 | 0 | } |
1792 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'h' ) |
1793 | 0 | && ( type_string[ 1 ] == (uint8_t) 'a' ) ) |
1794 | 0 | { |
1795 | 0 | result = libewf_value_reader_read_serialized_string_base16( |
1796 | 0 | value_reader, |
1797 | 0 | lef_file_entry->md5_hash, |
1798 | 0 | error ); |
1799 | |
|
1800 | 0 | if( result == -1 ) |
1801 | 0 | { |
1802 | 0 | libcerror_error_set( |
1803 | 0 | error, |
1804 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1805 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1806 | 0 | "%s: unable to read MD5 hash value.", |
1807 | 0 | function ); |
1808 | |
|
1809 | 0 | goto on_error; |
1810 | 0 | } |
1811 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1812 | | if( libcnotify_verbose != 0 ) |
1813 | | { |
1814 | | libcnotify_printf( |
1815 | | "%s: type: %3s with value:\n", |
1816 | | function, |
1817 | | (char *) type_string ); |
1818 | | libcnotify_print_data( |
1819 | | lef_file_entry->md5_hash->data, |
1820 | | lef_file_entry->md5_hash->data_size, |
1821 | | 0 ); |
1822 | | } |
1823 | | #endif |
1824 | 0 | known_value = 1; |
1825 | 0 | } |
1826 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'i' ) |
1827 | 0 | && ( type_string[ 1 ] == (uint8_t) 'd' ) ) |
1828 | 0 | { |
1829 | 0 | result = libewf_value_reader_read_integer_unsigned( |
1830 | 0 | value_reader, |
1831 | 0 | &( lef_file_entry->identifier ), |
1832 | 0 | error ); |
1833 | |
|
1834 | 0 | if( result == -1 ) |
1835 | 0 | { |
1836 | 0 | libcerror_error_set( |
1837 | 0 | error, |
1838 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1839 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1840 | 0 | "%s: unable to read identifier value.", |
1841 | 0 | function ); |
1842 | |
|
1843 | 0 | goto on_error; |
1844 | 0 | } |
1845 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1846 | | if( libcnotify_verbose != 0 ) |
1847 | | { |
1848 | | libcnotify_printf( |
1849 | | "%s: type: %3s with value\t\t\t:", |
1850 | | function, |
1851 | | (char *) type_string ); |
1852 | | |
1853 | | if( result != 0 ) |
1854 | | { |
1855 | | libcnotify_printf( |
1856 | | " %" PRIu64 "", |
1857 | | lef_file_entry->identifier ); |
1858 | | } |
1859 | | libcnotify_printf( |
1860 | | "\n" ); |
1861 | | } |
1862 | | #endif |
1863 | 0 | known_value = 1; |
1864 | 0 | } |
1865 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'j' ) |
1866 | 0 | && ( type_string[ 1 ] == (uint8_t) 'q' ) ) |
1867 | 0 | { |
1868 | | /* TODO implement */ |
1869 | 0 | } |
1870 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'l' ) |
1871 | 0 | && ( type_string[ 1 ] == (uint8_t) 'o' ) ) |
1872 | 0 | { |
1873 | 0 | result = libewf_value_reader_read_integer_signed( |
1874 | 0 | value_reader, |
1875 | 0 | &( lef_file_entry->logical_offset ), |
1876 | 0 | error ); |
1877 | |
|
1878 | 0 | if( result == -1 ) |
1879 | 0 | { |
1880 | 0 | libcerror_error_set( |
1881 | 0 | error, |
1882 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1883 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1884 | 0 | "%s: unable to read logical offset value.", |
1885 | 0 | function ); |
1886 | |
|
1887 | 0 | goto on_error; |
1888 | 0 | } |
1889 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1890 | | if( libcnotify_verbose != 0 ) |
1891 | | { |
1892 | | libcnotify_printf( |
1893 | | "%s: type: %3s with value\t\t\t:", |
1894 | | function, |
1895 | | (char *) type_string ); |
1896 | | |
1897 | | if( result != 0 ) |
1898 | | { |
1899 | | libcnotify_printf( |
1900 | | " %" PRIi64 "", |
1901 | | lef_file_entry->logical_offset ); |
1902 | | } |
1903 | | libcnotify_printf( |
1904 | | "\n" ); |
1905 | | } |
1906 | | #endif |
1907 | 0 | known_value = 1; |
1908 | 0 | } |
1909 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'l' ) |
1910 | 0 | && ( type_string[ 1 ] == (uint8_t) 's' ) ) |
1911 | 0 | { |
1912 | 0 | result = libewf_value_reader_read_integer_unsigned( |
1913 | 0 | value_reader, |
1914 | 0 | (uint64_t *) &( lef_file_entry->size ), |
1915 | 0 | error ); |
1916 | |
|
1917 | 0 | if( result == -1 ) |
1918 | 0 | { |
1919 | 0 | libcerror_error_set( |
1920 | 0 | error, |
1921 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1922 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1923 | 0 | "%s: unable to read size value.", |
1924 | 0 | function ); |
1925 | |
|
1926 | 0 | goto on_error; |
1927 | 0 | } |
1928 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1929 | | if( libcnotify_verbose != 0 ) |
1930 | | { |
1931 | | libcnotify_printf( |
1932 | | "%s: type: %3s with value\t\t\t:", |
1933 | | function, |
1934 | | (char *) type_string ); |
1935 | | |
1936 | | if( result != 0 ) |
1937 | | { |
1938 | | libcnotify_printf( |
1939 | | " %" PRIu64 "", |
1940 | | lef_file_entry->size ); |
1941 | | } |
1942 | | libcnotify_printf( |
1943 | | "\n" ); |
1944 | | } |
1945 | | #endif |
1946 | 0 | known_value = 1; |
1947 | 0 | } |
1948 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'm' ) |
1949 | 0 | && ( type_string[ 1 ] == (uint8_t) 'o' ) ) |
1950 | 0 | { |
1951 | 0 | result = libewf_value_reader_read_integer_signed( |
1952 | 0 | value_reader, |
1953 | 0 | &( lef_file_entry->entry_modification_time ), |
1954 | 0 | error ); |
1955 | |
|
1956 | 0 | if( result == -1 ) |
1957 | 0 | { |
1958 | 0 | libcerror_error_set( |
1959 | 0 | error, |
1960 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
1961 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
1962 | 0 | "%s: unable to read modification time value.", |
1963 | 0 | function ); |
1964 | |
|
1965 | 0 | goto on_error; |
1966 | 0 | } |
1967 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1968 | | if( libcnotify_verbose != 0 ) |
1969 | | { |
1970 | | libcnotify_printf( |
1971 | | "%s: type: %3s with value\t\t\t:", |
1972 | | function, |
1973 | | (char *) type_string ); |
1974 | | |
1975 | | if( result != 0 ) |
1976 | | { |
1977 | | libcnotify_printf( |
1978 | | " %" PRIi64 "", |
1979 | | lef_file_entry->entry_modification_time ); |
1980 | | } |
1981 | | libcnotify_printf( |
1982 | | "\n" ); |
1983 | | } |
1984 | | #endif |
1985 | 0 | known_value = 1; |
1986 | 0 | } |
1987 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'p' ) |
1988 | 0 | && ( type_string[ 1 ] == (uint8_t) 'm' ) ) |
1989 | 0 | { |
1990 | 0 | result = libewf_value_reader_read_integer_signed( |
1991 | 0 | value_reader, |
1992 | 0 | &value_64bit_signed, |
1993 | 0 | error ); |
1994 | |
|
1995 | 0 | if( result == -1 ) |
1996 | 0 | { |
1997 | 0 | libcerror_error_set( |
1998 | 0 | error, |
1999 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2000 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2001 | 0 | "%s: unable to read permission group index value.", |
2002 | 0 | function ); |
2003 | |
|
2004 | 0 | goto on_error; |
2005 | 0 | } |
2006 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2007 | | if( libcnotify_verbose != 0 ) |
2008 | | { |
2009 | | libcnotify_printf( |
2010 | | "%s: type: %3s with value\t\t\t:", |
2011 | | function, |
2012 | | (char *) type_string ); |
2013 | | |
2014 | | if( result != 0 ) |
2015 | | { |
2016 | | libcnotify_printf( |
2017 | | " %" PRIi64 "", |
2018 | | value_64bit_signed ); |
2019 | | } |
2020 | | libcnotify_printf( |
2021 | | "\n" ); |
2022 | | } |
2023 | | #endif |
2024 | 0 | if( result != 0 ) |
2025 | 0 | { |
2026 | 0 | if( ( value_64bit_signed < (int64_t) -1 ) |
2027 | 0 | || ( value_64bit_signed > (int64_t) INT_MAX ) ) |
2028 | 0 | { |
2029 | 0 | libcerror_error_set( |
2030 | 0 | error, |
2031 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2032 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
2033 | 0 | "%s: invalid permission group index value out of bounds.", |
2034 | 0 | function ); |
2035 | |
|
2036 | 0 | goto on_error; |
2037 | 0 | } |
2038 | 0 | lef_file_entry->permission_group_index = (int) value_64bit_signed; |
2039 | 0 | } |
2040 | 0 | known_value = 1; |
2041 | 0 | } |
2042 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'p' ) |
2043 | 0 | && ( type_string[ 1 ] == (uint8_t) 'o' ) ) |
2044 | 0 | { |
2045 | 0 | result = libewf_value_reader_read_integer_signed( |
2046 | 0 | value_reader, |
2047 | 0 | &( lef_file_entry->physical_offset ), |
2048 | 0 | error ); |
2049 | |
|
2050 | 0 | if( result == -1 ) |
2051 | 0 | { |
2052 | 0 | libcerror_error_set( |
2053 | 0 | error, |
2054 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2055 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2056 | 0 | "%s: unable to read physical offset value.", |
2057 | 0 | function ); |
2058 | |
|
2059 | 0 | goto on_error; |
2060 | 0 | } |
2061 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2062 | | if( libcnotify_verbose != 0 ) |
2063 | | { |
2064 | | libcnotify_printf( |
2065 | | "%s: type: %3s with value\t\t\t:", |
2066 | | function, |
2067 | | (char *) type_string ); |
2068 | | |
2069 | | if( result != 0 ) |
2070 | | { |
2071 | | libcnotify_printf( |
2072 | | " %" PRIi64 "", |
2073 | | lef_file_entry->physical_offset ); |
2074 | | } |
2075 | | libcnotify_printf( |
2076 | | "\n" ); |
2077 | | } |
2078 | | #endif |
2079 | 0 | known_value = 1; |
2080 | 0 | } |
2081 | 0 | else if( ( type_string[ 0 ] == (uint8_t) 'w' ) |
2082 | 0 | && ( type_string[ 1 ] == (uint8_t) 'r' ) ) |
2083 | 0 | { |
2084 | 0 | result = libewf_value_reader_read_integer_signed( |
2085 | 0 | value_reader, |
2086 | 0 | &( lef_file_entry->modification_time ), |
2087 | 0 | error ); |
2088 | |
|
2089 | 0 | if( result == -1 ) |
2090 | 0 | { |
2091 | 0 | libcerror_error_set( |
2092 | 0 | error, |
2093 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2094 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2095 | 0 | "%s: unable to read modification time value.", |
2096 | 0 | function ); |
2097 | |
|
2098 | 0 | goto on_error; |
2099 | 0 | } |
2100 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2101 | | if( libcnotify_verbose != 0 ) |
2102 | | { |
2103 | | libcnotify_printf( |
2104 | | "%s: type: %3s with value\t\t\t:", |
2105 | | function, |
2106 | | (char *) type_string ); |
2107 | | |
2108 | | if( result != 0 ) |
2109 | | { |
2110 | | libcnotify_printf( |
2111 | | " %" PRIi64 "", |
2112 | | lef_file_entry->modification_time ); |
2113 | | } |
2114 | | libcnotify_printf( |
2115 | | "\n" ); |
2116 | | } |
2117 | | #endif |
2118 | 0 | known_value = 1; |
2119 | 0 | } |
2120 | 0 | } |
2121 | 0 | else if( type_string_size == 2 ) |
2122 | 0 | { |
2123 | 0 | if( type_string[ 0 ] == (uint8_t) 'n' ) |
2124 | 0 | { |
2125 | 0 | if( libewf_value_reader_read_data( |
2126 | 0 | value_reader, |
2127 | 0 | &value_data, |
2128 | 0 | &value_data_size, |
2129 | 0 | error ) != 1 ) |
2130 | 0 | { |
2131 | 0 | libcerror_error_set( |
2132 | 0 | error, |
2133 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2134 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2135 | 0 | "%s: unable to read read name value data.", |
2136 | 0 | function ); |
2137 | |
|
2138 | 0 | goto on_error; |
2139 | 0 | } |
2140 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2141 | | if( libcnotify_verbose != 0 ) |
2142 | | { |
2143 | | libcnotify_printf( |
2144 | | "%s: type: %3s with value:\n", |
2145 | | function, |
2146 | | (char *) type_string ); |
2147 | | libcnotify_print_data( |
2148 | | value_data, |
2149 | | value_data_size, |
2150 | | 0 ); |
2151 | | } |
2152 | | #endif |
2153 | 0 | if( ( value_data != NULL ) |
2154 | 0 | && ( value_data_size > 0 ) ) |
2155 | 0 | { |
2156 | 0 | lef_file_entry->name_data = (uint8_t *) memory_allocate( |
2157 | 0 | value_data_size ); |
2158 | |
|
2159 | 0 | if( lef_file_entry->name_data == NULL ) |
2160 | 0 | { |
2161 | 0 | libcerror_error_set( |
2162 | 0 | error, |
2163 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
2164 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
2165 | 0 | "%s: unable to create name data.", |
2166 | 0 | function ); |
2167 | |
|
2168 | 0 | goto on_error; |
2169 | 0 | } |
2170 | 0 | lef_file_entry->name_data_size = value_data_size; |
2171 | |
|
2172 | 0 | if( memory_copy( |
2173 | 0 | lef_file_entry->name_data, |
2174 | 0 | value_data, |
2175 | 0 | value_data_size ) == NULL ) |
2176 | 0 | { |
2177 | 0 | libcerror_error_set( |
2178 | 0 | error, |
2179 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
2180 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
2181 | 0 | "%s: unable to copy name data.", |
2182 | 0 | function ); |
2183 | |
|
2184 | 0 | goto on_error; |
2185 | 0 | } |
2186 | 0 | } |
2187 | 0 | known_value = 1; |
2188 | 0 | } |
2189 | 0 | else if( type_string[ 0 ] == (uint8_t) 'p' ) |
2190 | 0 | { |
2191 | 0 | if( libewf_value_reader_read_data( |
2192 | 0 | value_reader, |
2193 | 0 | &value_data, |
2194 | 0 | &value_data_size, |
2195 | 0 | error ) != 1 ) |
2196 | 0 | { |
2197 | 0 | libcerror_error_set( |
2198 | 0 | error, |
2199 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2200 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2201 | 0 | "%s: unable to read read entry type value data.", |
2202 | 0 | function ); |
2203 | |
|
2204 | 0 | goto on_error; |
2205 | 0 | } |
2206 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2207 | | if( libcnotify_verbose != 0 ) |
2208 | | { |
2209 | | libcnotify_printf( |
2210 | | "%s: type: %3s with value:\n", |
2211 | | function, |
2212 | | (char *) type_string ); |
2213 | | libcnotify_print_data( |
2214 | | value_data, |
2215 | | value_data_size, |
2216 | | 0 ); |
2217 | | } |
2218 | | #endif |
2219 | | /* p = 1 if directory |
2220 | | * p = empty if file |
2221 | | */ |
2222 | 0 | if( value_data == NULL ) |
2223 | 0 | { |
2224 | 0 | lef_file_entry->type = LIBEWF_FILE_ENTRY_TYPE_FILE; |
2225 | 0 | } |
2226 | 0 | else if( ( value_data_size == 2 ) |
2227 | 0 | && ( value_data[ 0 ] == (uint8_t) '1' ) |
2228 | 0 | && ( value_data[ 1 ] == 0 ) ) |
2229 | 0 | { |
2230 | 0 | lef_file_entry->type = LIBEWF_FILE_ENTRY_TYPE_DIRECTORY; |
2231 | 0 | } |
2232 | 0 | known_value = 1; |
2233 | 0 | } |
2234 | 0 | } |
2235 | 0 | if( known_value == 0 ) |
2236 | 0 | { |
2237 | 0 | if( libewf_value_reader_read_data( |
2238 | 0 | value_reader, |
2239 | 0 | &value_data, |
2240 | 0 | &value_data_size, |
2241 | 0 | error ) != 1 ) |
2242 | 0 | { |
2243 | 0 | libcerror_error_set( |
2244 | 0 | error, |
2245 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2246 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2247 | 0 | "%s: unable to read read %s value data.", |
2248 | 0 | function, |
2249 | 0 | (char *) type_string ); |
2250 | |
|
2251 | 0 | goto on_error; |
2252 | 0 | } |
2253 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2254 | | if( libcnotify_verbose != 0 ) |
2255 | | { |
2256 | | libcnotify_printf( |
2257 | | "%s: type: %3s with value:\n", |
2258 | | function, |
2259 | | (char *) type_string ); |
2260 | | libcnotify_print_data( |
2261 | | value_data, |
2262 | | value_data_size, |
2263 | | 0 ); |
2264 | | } |
2265 | | #endif |
2266 | 0 | } |
2267 | 0 | } |
2268 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2269 | | if( libcnotify_verbose != 0 ) |
2270 | | { |
2271 | | libcnotify_printf( |
2272 | | "\n" ); |
2273 | | } |
2274 | | #endif |
2275 | 0 | if( ( number_of_types != ( value_reader->value_index + 1 ) ) |
2276 | 0 | || ( value_reader->buffer_offset < value_reader->buffer_size ) ) |
2277 | 0 | { |
2278 | 0 | libcerror_error_set( |
2279 | 0 | error, |
2280 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2281 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
2282 | 0 | "%s: mismatch in number of types and values.", |
2283 | 0 | function ); |
2284 | |
|
2285 | 0 | goto on_error; |
2286 | 0 | } |
2287 | 0 | if( libewf_value_reader_free( |
2288 | 0 | &value_reader, |
2289 | 0 | error ) != 1 ) |
2290 | 0 | { |
2291 | 0 | libcerror_error_set( |
2292 | 0 | error, |
2293 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2294 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
2295 | 0 | "%s: unable to free value reader.", |
2296 | 0 | function ); |
2297 | |
|
2298 | 0 | goto on_error; |
2299 | 0 | } |
2300 | 0 | return( 1 ); |
2301 | | |
2302 | 0 | on_error: |
2303 | 0 | if( lef_file_entry->name_data != NULL ) |
2304 | 0 | { |
2305 | 0 | memory_free( |
2306 | 0 | lef_file_entry->name_data ); |
2307 | |
|
2308 | 0 | lef_file_entry->name_data = NULL; |
2309 | 0 | } |
2310 | 0 | lef_file_entry->name_data_size = 0; |
2311 | |
|
2312 | 0 | if( value_reader != NULL ) |
2313 | 0 | { |
2314 | 0 | libewf_value_reader_free( |
2315 | 0 | &value_reader, |
2316 | 0 | NULL ); |
2317 | 0 | } |
2318 | 0 | return( -1 ); |
2319 | 0 | } |
2320 | | |
2321 | | /* Retrieves the identifier |
2322 | | * Returns 1 if successful or -1 on error |
2323 | | */ |
2324 | | int libewf_lef_file_entry_get_identifier( |
2325 | | libewf_lef_file_entry_t *lef_file_entry, |
2326 | | uint64_t *identifier, |
2327 | | libcerror_error_t **error ) |
2328 | 0 | { |
2329 | 0 | static char *function = "libewf_lef_file_entry_get_identifier"; |
2330 | |
|
2331 | 0 | if( lef_file_entry == NULL ) |
2332 | 0 | { |
2333 | 0 | libcerror_error_set( |
2334 | 0 | error, |
2335 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2336 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2337 | 0 | "%s: invalid file entry.", |
2338 | 0 | function ); |
2339 | |
|
2340 | 0 | return( -1 ); |
2341 | 0 | } |
2342 | 0 | if( identifier == NULL ) |
2343 | 0 | { |
2344 | 0 | libcerror_error_set( |
2345 | 0 | error, |
2346 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2347 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2348 | 0 | "%s: invalid identifier.", |
2349 | 0 | function ); |
2350 | |
|
2351 | 0 | return( -1 ); |
2352 | 0 | } |
2353 | 0 | *identifier = lef_file_entry->identifier; |
2354 | |
|
2355 | 0 | return( 1 ); |
2356 | 0 | } |
2357 | | |
2358 | | /* Retrieves the type |
2359 | | * Returns 1 if successful or -1 on error |
2360 | | */ |
2361 | | int libewf_lef_file_entry_get_type( |
2362 | | libewf_lef_file_entry_t *lef_file_entry, |
2363 | | uint8_t *type, |
2364 | | libcerror_error_t **error ) |
2365 | 0 | { |
2366 | 0 | static char *function = "libewf_lef_file_entry_get_type"; |
2367 | |
|
2368 | 0 | if( lef_file_entry == NULL ) |
2369 | 0 | { |
2370 | 0 | libcerror_error_set( |
2371 | 0 | error, |
2372 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2373 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2374 | 0 | "%s: invalid file entry.", |
2375 | 0 | function ); |
2376 | |
|
2377 | 0 | return( -1 ); |
2378 | 0 | } |
2379 | 0 | if( type == NULL ) |
2380 | 0 | { |
2381 | 0 | libcerror_error_set( |
2382 | 0 | error, |
2383 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2384 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2385 | 0 | "%s: invalid type.", |
2386 | 0 | function ); |
2387 | |
|
2388 | 0 | return( -1 ); |
2389 | 0 | } |
2390 | 0 | *type = lef_file_entry->type; |
2391 | |
|
2392 | 0 | return( 1 ); |
2393 | 0 | } |
2394 | | |
2395 | | /* Retrieves the flags |
2396 | | * Returns 1 if successful or -1 on error |
2397 | | */ |
2398 | | int libewf_lef_file_entry_get_flags( |
2399 | | libewf_lef_file_entry_t *lef_file_entry, |
2400 | | uint32_t *flags, |
2401 | | libcerror_error_t **error ) |
2402 | 0 | { |
2403 | 0 | static char *function = "libewf_lef_file_entry_get_flags"; |
2404 | |
|
2405 | 0 | if( lef_file_entry == NULL ) |
2406 | 0 | { |
2407 | 0 | libcerror_error_set( |
2408 | 0 | error, |
2409 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2410 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2411 | 0 | "%s: invalid file entry.", |
2412 | 0 | function ); |
2413 | |
|
2414 | 0 | return( -1 ); |
2415 | 0 | } |
2416 | 0 | if( flags == NULL ) |
2417 | 0 | { |
2418 | 0 | libcerror_error_set( |
2419 | 0 | error, |
2420 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2421 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2422 | 0 | "%s: invalid flags.", |
2423 | 0 | function ); |
2424 | |
|
2425 | 0 | return( -1 ); |
2426 | 0 | } |
2427 | 0 | *flags = lef_file_entry->flags; |
2428 | |
|
2429 | 0 | return( 1 ); |
2430 | 0 | } |
2431 | | |
2432 | | /* Retrieves the data offset |
2433 | | * Returns 1 if successful or -1 on error |
2434 | | */ |
2435 | | int libewf_lef_file_entry_get_data_offset( |
2436 | | libewf_lef_file_entry_t *lef_file_entry, |
2437 | | off64_t *data_offset, |
2438 | | libcerror_error_t **error ) |
2439 | 0 | { |
2440 | 0 | static char *function = "libewf_lef_file_entry_get_data_offset"; |
2441 | |
|
2442 | 0 | if( lef_file_entry == NULL ) |
2443 | 0 | { |
2444 | 0 | libcerror_error_set( |
2445 | 0 | error, |
2446 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2447 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2448 | 0 | "%s: invalid file entry.", |
2449 | 0 | function ); |
2450 | |
|
2451 | 0 | return( -1 ); |
2452 | 0 | } |
2453 | 0 | if( data_offset == NULL ) |
2454 | 0 | { |
2455 | 0 | libcerror_error_set( |
2456 | 0 | error, |
2457 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2458 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2459 | 0 | "%s: invalid data offset.", |
2460 | 0 | function ); |
2461 | |
|
2462 | 0 | return( -1 ); |
2463 | 0 | } |
2464 | 0 | *data_offset = lef_file_entry->data_offset; |
2465 | |
|
2466 | 0 | return( 1 ); |
2467 | 0 | } |
2468 | | |
2469 | | /* Retrieves the data size |
2470 | | * Returns 1 if successful or -1 on error |
2471 | | */ |
2472 | | int libewf_lef_file_entry_get_data_size( |
2473 | | libewf_lef_file_entry_t *lef_file_entry, |
2474 | | size64_t *data_size, |
2475 | | libcerror_error_t **error ) |
2476 | 0 | { |
2477 | 0 | static char *function = "libewf_lef_file_entry_get_data_size"; |
2478 | |
|
2479 | 0 | if( lef_file_entry == NULL ) |
2480 | 0 | { |
2481 | 0 | libcerror_error_set( |
2482 | 0 | error, |
2483 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2484 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2485 | 0 | "%s: invalid file entry.", |
2486 | 0 | function ); |
2487 | |
|
2488 | 0 | return( -1 ); |
2489 | 0 | } |
2490 | 0 | if( data_size == NULL ) |
2491 | 0 | { |
2492 | 0 | libcerror_error_set( |
2493 | 0 | error, |
2494 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2495 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2496 | 0 | "%s: invalid data size.", |
2497 | 0 | function ); |
2498 | |
|
2499 | 0 | return( -1 ); |
2500 | 0 | } |
2501 | 0 | *data_size = lef_file_entry->data_size; |
2502 | |
|
2503 | 0 | return( 1 ); |
2504 | 0 | } |
2505 | | |
2506 | | /* Retrieves the logical offset |
2507 | | * Returns 1 if successful or -1 on error |
2508 | | */ |
2509 | | int libewf_lef_file_entry_get_logical_offset( |
2510 | | libewf_lef_file_entry_t *lef_file_entry, |
2511 | | off64_t *logical_offset, |
2512 | | libcerror_error_t **error ) |
2513 | 0 | { |
2514 | 0 | static char *function = "libewf_lef_file_entry_get_logical_offset"; |
2515 | |
|
2516 | 0 | if( lef_file_entry == NULL ) |
2517 | 0 | { |
2518 | 0 | libcerror_error_set( |
2519 | 0 | error, |
2520 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2521 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2522 | 0 | "%s: invalid file entry.", |
2523 | 0 | function ); |
2524 | |
|
2525 | 0 | return( -1 ); |
2526 | 0 | } |
2527 | 0 | if( logical_offset == NULL ) |
2528 | 0 | { |
2529 | 0 | libcerror_error_set( |
2530 | 0 | error, |
2531 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2532 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2533 | 0 | "%s: invalid logical offset.", |
2534 | 0 | function ); |
2535 | |
|
2536 | 0 | return( -1 ); |
2537 | 0 | } |
2538 | 0 | *logical_offset = lef_file_entry->logical_offset; |
2539 | |
|
2540 | 0 | return( 1 ); |
2541 | 0 | } |
2542 | | |
2543 | | /* Retrieves the physical offset |
2544 | | * Returns 1 if successful or -1 on error |
2545 | | */ |
2546 | | int libewf_lef_file_entry_get_physical_offset( |
2547 | | libewf_lef_file_entry_t *lef_file_entry, |
2548 | | off64_t *physical_offset, |
2549 | | libcerror_error_t **error ) |
2550 | 0 | { |
2551 | 0 | static char *function = "libewf_lef_file_entry_get_physical_offset"; |
2552 | |
|
2553 | 0 | if( lef_file_entry == NULL ) |
2554 | 0 | { |
2555 | 0 | libcerror_error_set( |
2556 | 0 | error, |
2557 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2558 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2559 | 0 | "%s: invalid file entry.", |
2560 | 0 | function ); |
2561 | |
|
2562 | 0 | return( -1 ); |
2563 | 0 | } |
2564 | 0 | if( physical_offset == NULL ) |
2565 | 0 | { |
2566 | 0 | libcerror_error_set( |
2567 | 0 | error, |
2568 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2569 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2570 | 0 | "%s: invalid physical offset.", |
2571 | 0 | function ); |
2572 | |
|
2573 | 0 | return( -1 ); |
2574 | 0 | } |
2575 | 0 | *physical_offset = lef_file_entry->physical_offset; |
2576 | |
|
2577 | 0 | return( 1 ); |
2578 | 0 | } |
2579 | | |
2580 | | /* Retrieves the duplicate data offset |
2581 | | * Returns 1 if successful or -1 on error |
2582 | | */ |
2583 | | int libewf_lef_file_entry_get_duplicate_data_offset( |
2584 | | libewf_lef_file_entry_t *lef_file_entry, |
2585 | | off64_t *duplicate_data_offset, |
2586 | | libcerror_error_t **error ) |
2587 | 0 | { |
2588 | 0 | static char *function = "libewf_lef_file_entry_get_duplicate_data_offset"; |
2589 | |
|
2590 | 0 | if( lef_file_entry == NULL ) |
2591 | 0 | { |
2592 | 0 | libcerror_error_set( |
2593 | 0 | error, |
2594 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2595 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2596 | 0 | "%s: invalid file entry.", |
2597 | 0 | function ); |
2598 | |
|
2599 | 0 | return( -1 ); |
2600 | 0 | } |
2601 | 0 | if( duplicate_data_offset == NULL ) |
2602 | 0 | { |
2603 | 0 | libcerror_error_set( |
2604 | 0 | error, |
2605 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2606 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2607 | 0 | "%s: invalid duplicate data offset.", |
2608 | 0 | function ); |
2609 | |
|
2610 | 0 | return( -1 ); |
2611 | 0 | } |
2612 | 0 | *duplicate_data_offset = lef_file_entry->duplicate_data_offset; |
2613 | |
|
2614 | 0 | return( 1 ); |
2615 | 0 | } |
2616 | | |
2617 | | /* Retrieves the size of the UTF-8 encoded GUID |
2618 | | * The returned size includes the end of string character |
2619 | | * Returns 1 if successful or -1 on error |
2620 | | */ |
2621 | | int libewf_lef_file_entry_get_utf8_guid_size( |
2622 | | libewf_lef_file_entry_t *lef_file_entry, |
2623 | | size_t *utf8_string_size, |
2624 | | libcerror_error_t **error ) |
2625 | 0 | { |
2626 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_guid_size"; |
2627 | 0 | int result = 0; |
2628 | |
|
2629 | 0 | if( lef_file_entry == NULL ) |
2630 | 0 | { |
2631 | 0 | libcerror_error_set( |
2632 | 0 | error, |
2633 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2634 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2635 | 0 | "%s: invalid file entry.", |
2636 | 0 | function ); |
2637 | |
|
2638 | 0 | return( -1 ); |
2639 | 0 | } |
2640 | 0 | result = libewf_serialized_string_get_utf8_string_size( |
2641 | 0 | lef_file_entry->guid, |
2642 | 0 | utf8_string_size, |
2643 | 0 | error ); |
2644 | |
|
2645 | 0 | if( result == -1 ) |
2646 | 0 | { |
2647 | 0 | libcerror_error_set( |
2648 | 0 | error, |
2649 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2650 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2651 | 0 | "%s: unable to retrieve GUID UTF-8 string size.", |
2652 | 0 | function ); |
2653 | |
|
2654 | 0 | return( -1 ); |
2655 | 0 | } |
2656 | 0 | return( 1 ); |
2657 | 0 | } |
2658 | | |
2659 | | /* Retrieves the UTF-8 encoded GUID value |
2660 | | * The size should include the end of string character |
2661 | | * Returns 1 if successful or -1 on error |
2662 | | */ |
2663 | | int libewf_lef_file_entry_get_utf8_guid( |
2664 | | libewf_lef_file_entry_t *lef_file_entry, |
2665 | | uint8_t *utf8_string, |
2666 | | size_t utf8_string_size, |
2667 | | libcerror_error_t **error ) |
2668 | 0 | { |
2669 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_guid"; |
2670 | 0 | int result = 0; |
2671 | |
|
2672 | 0 | if( lef_file_entry == NULL ) |
2673 | 0 | { |
2674 | 0 | libcerror_error_set( |
2675 | 0 | error, |
2676 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2677 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2678 | 0 | "%s: invalid file entry.", |
2679 | 0 | function ); |
2680 | |
|
2681 | 0 | return( -1 ); |
2682 | 0 | } |
2683 | 0 | result = libewf_serialized_string_get_utf8_string( |
2684 | 0 | lef_file_entry->guid, |
2685 | 0 | utf8_string, |
2686 | 0 | utf8_string_size, |
2687 | 0 | error ); |
2688 | |
|
2689 | 0 | if( result == -1 ) |
2690 | 0 | { |
2691 | 0 | libcerror_error_set( |
2692 | 0 | error, |
2693 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2694 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2695 | 0 | "%s: unable to copy GUID to UTF-8 string.", |
2696 | 0 | function ); |
2697 | |
|
2698 | 0 | return( -1 ); |
2699 | 0 | } |
2700 | 0 | return( 1 ); |
2701 | 0 | } |
2702 | | |
2703 | | /* Retrieves the size of the UTF-16 encoded GUID |
2704 | | * The returned size includes the end of string character |
2705 | | * Returns 1 if successful or -1 on error |
2706 | | */ |
2707 | | int libewf_lef_file_entry_get_utf16_guid_size( |
2708 | | libewf_lef_file_entry_t *lef_file_entry, |
2709 | | size_t *utf16_string_size, |
2710 | | libcerror_error_t **error ) |
2711 | 0 | { |
2712 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_guid_size"; |
2713 | 0 | int result = 0; |
2714 | |
|
2715 | 0 | if( lef_file_entry == NULL ) |
2716 | 0 | { |
2717 | 0 | libcerror_error_set( |
2718 | 0 | error, |
2719 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2720 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2721 | 0 | "%s: invalid file entry.", |
2722 | 0 | function ); |
2723 | |
|
2724 | 0 | return( -1 ); |
2725 | 0 | } |
2726 | 0 | result = libewf_serialized_string_get_utf16_string_size( |
2727 | 0 | lef_file_entry->guid, |
2728 | 0 | utf16_string_size, |
2729 | 0 | error ); |
2730 | |
|
2731 | 0 | if( result == -1 ) |
2732 | 0 | { |
2733 | 0 | libcerror_error_set( |
2734 | 0 | error, |
2735 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2736 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2737 | 0 | "%s: unable to retrieve GUID UTF-16 string size.", |
2738 | 0 | function ); |
2739 | |
|
2740 | 0 | return( -1 ); |
2741 | 0 | } |
2742 | 0 | return( 1 ); |
2743 | 0 | } |
2744 | | |
2745 | | /* Retrieves the UTF-16 encoded GUID value |
2746 | | * The size should include the end of string character |
2747 | | * Returns 1 if successful or -1 on error |
2748 | | */ |
2749 | | int libewf_lef_file_entry_get_utf16_guid( |
2750 | | libewf_lef_file_entry_t *lef_file_entry, |
2751 | | uint16_t *utf16_string, |
2752 | | size_t utf16_string_size, |
2753 | | libcerror_error_t **error ) |
2754 | 0 | { |
2755 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_guid"; |
2756 | 0 | int result = 0; |
2757 | |
|
2758 | 0 | if( lef_file_entry == NULL ) |
2759 | 0 | { |
2760 | 0 | libcerror_error_set( |
2761 | 0 | error, |
2762 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2763 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2764 | 0 | "%s: invalid file entry.", |
2765 | 0 | function ); |
2766 | |
|
2767 | 0 | return( -1 ); |
2768 | 0 | } |
2769 | 0 | result = libewf_serialized_string_get_utf16_string( |
2770 | 0 | lef_file_entry->guid, |
2771 | 0 | utf16_string, |
2772 | 0 | utf16_string_size, |
2773 | 0 | error ); |
2774 | |
|
2775 | 0 | if( result == -1 ) |
2776 | 0 | { |
2777 | 0 | libcerror_error_set( |
2778 | 0 | error, |
2779 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2780 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2781 | 0 | "%s: unable to copy GUID to UTF-16 string.", |
2782 | 0 | function ); |
2783 | |
|
2784 | 0 | return( -1 ); |
2785 | 0 | } |
2786 | 0 | return( 1 ); |
2787 | 0 | } |
2788 | | |
2789 | | /* Retrieves the size of the UTF-8 encoded name |
2790 | | * This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode |
2791 | | * The returned size includes the end of string character |
2792 | | * Returns 1 if successful or -1 on error |
2793 | | */ |
2794 | | int libewf_lef_file_entry_get_utf8_name_size( |
2795 | | libewf_lef_file_entry_t *lef_file_entry, |
2796 | | size_t *utf8_string_size, |
2797 | | libcerror_error_t **error ) |
2798 | 0 | { |
2799 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_name_size"; |
2800 | 0 | size_t safe_utf8_string_size = 0; |
2801 | |
|
2802 | 0 | if( lef_file_entry == NULL ) |
2803 | 0 | { |
2804 | 0 | libcerror_error_set( |
2805 | 0 | error, |
2806 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2807 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2808 | 0 | "%s: invalid file entry.", |
2809 | 0 | function ); |
2810 | |
|
2811 | 0 | return( -1 ); |
2812 | 0 | } |
2813 | 0 | if( utf8_string_size == NULL ) |
2814 | 0 | { |
2815 | 0 | libcerror_error_set( |
2816 | 0 | error, |
2817 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2818 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2819 | 0 | "%s: invalid UTF-8 string size.", |
2820 | 0 | function ); |
2821 | |
|
2822 | 0 | return( -1 ); |
2823 | 0 | } |
2824 | 0 | if( ( lef_file_entry->name_data != NULL ) |
2825 | 0 | && ( lef_file_entry->name_data_size > 0 ) ) |
2826 | 0 | { |
2827 | 0 | if( libuna_utf8_string_size_from_utf16_stream( |
2828 | 0 | lef_file_entry->name_data, |
2829 | 0 | lef_file_entry->name_data_size, |
2830 | 0 | LIBUNA_ENDIAN_LITTLE | LIBUNA_UTF16_STREAM_ALLOW_UNPAIRED_SURROGATE, |
2831 | 0 | &safe_utf8_string_size, |
2832 | 0 | error ) != 1 ) |
2833 | 0 | { |
2834 | 0 | libcerror_error_set( |
2835 | 0 | error, |
2836 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2837 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2838 | 0 | "%s: unable to retrieve UTF-8 string size.", |
2839 | 0 | function ); |
2840 | |
|
2841 | 0 | return( -1 ); |
2842 | 0 | } |
2843 | 0 | } |
2844 | 0 | *utf8_string_size = safe_utf8_string_size; |
2845 | |
|
2846 | 0 | return( 1 ); |
2847 | 0 | } |
2848 | | |
2849 | | /* Retrieves the UTF-8 encoded name value |
2850 | | * This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode |
2851 | | * The size should include the end of string character |
2852 | | * Returns 1 if successful or -1 on error |
2853 | | */ |
2854 | | int libewf_lef_file_entry_get_utf8_name( |
2855 | | libewf_lef_file_entry_t *lef_file_entry, |
2856 | | uint8_t *utf8_string, |
2857 | | size_t utf8_string_size, |
2858 | | libcerror_error_t **error ) |
2859 | 0 | { |
2860 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_name"; |
2861 | |
|
2862 | 0 | if( lef_file_entry == NULL ) |
2863 | 0 | { |
2864 | 0 | libcerror_error_set( |
2865 | 0 | error, |
2866 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2867 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2868 | 0 | "%s: invalid file entry.", |
2869 | 0 | function ); |
2870 | |
|
2871 | 0 | return( -1 ); |
2872 | 0 | } |
2873 | 0 | if( libuna_utf8_string_copy_from_utf16_stream( |
2874 | 0 | utf8_string, |
2875 | 0 | utf8_string_size, |
2876 | 0 | lef_file_entry->name_data, |
2877 | 0 | lef_file_entry->name_data_size, |
2878 | 0 | LIBUNA_ENDIAN_LITTLE | LIBUNA_UTF16_STREAM_ALLOW_UNPAIRED_SURROGATE, |
2879 | 0 | error ) != 1 ) |
2880 | 0 | { |
2881 | 0 | libcerror_error_set( |
2882 | 0 | error, |
2883 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2884 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2885 | 0 | "%s: unable to retrieve UTF-8 string.", |
2886 | 0 | function ); |
2887 | |
|
2888 | 0 | return( -1 ); |
2889 | 0 | } |
2890 | 0 | return( 1 ); |
2891 | 0 | } |
2892 | | |
2893 | | /* Compares an UTF-8 string with a file entry name |
2894 | | * Returns LIBUNA_COMPARE_LESS, LIBUNA_COMPARE_EQUAL, LIBUNA_COMPARE_GREATER if successful or -1 on error |
2895 | | */ |
2896 | | int libewf_lef_file_entry_compare_name_with_utf8_string( |
2897 | | libewf_lef_file_entry_t *lef_file_entry, |
2898 | | const uint8_t *utf8_string, |
2899 | | size_t utf8_string_length, |
2900 | | libcerror_error_t **error ) |
2901 | 0 | { |
2902 | 0 | static char *function = "libewf_lef_file_entry_compare_name_with_utf8_string"; |
2903 | 0 | int result = 0; |
2904 | |
|
2905 | 0 | if( lef_file_entry == NULL ) |
2906 | 0 | { |
2907 | 0 | libcerror_error_set( |
2908 | 0 | error, |
2909 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2910 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2911 | 0 | "%s: invalid file entry.", |
2912 | 0 | function ); |
2913 | |
|
2914 | 0 | return( -1 ); |
2915 | 0 | } |
2916 | 0 | result = libuna_utf8_string_compare_with_utf16_stream( |
2917 | 0 | utf8_string, |
2918 | 0 | utf8_string_length, |
2919 | 0 | lef_file_entry->name_data, |
2920 | 0 | lef_file_entry->name_data_size, |
2921 | 0 | LIBUNA_ENDIAN_LITTLE | LIBUNA_UTF16_STREAM_ALLOW_UNPAIRED_SURROGATE, |
2922 | 0 | error ); |
2923 | |
|
2924 | 0 | if( result == -1 ) |
2925 | 0 | { |
2926 | 0 | libcerror_error_set( |
2927 | 0 | error, |
2928 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2929 | 0 | LIBCERROR_RUNTIME_ERROR_GENERIC, |
2930 | 0 | "%s: unable to compare name with UTF-8 string.", |
2931 | 0 | function ); |
2932 | |
|
2933 | 0 | return( -1 ); |
2934 | 0 | } |
2935 | 0 | return( result ); |
2936 | 0 | } |
2937 | | |
2938 | | /* Retrieves the size of the UTF-16 encoded name |
2939 | | * This function uses UCS-2 (with surrogates) to support characters outside Unicode |
2940 | | * The returned size includes the end of string character |
2941 | | * Returns 1 if successful or -1 on error |
2942 | | */ |
2943 | | int libewf_lef_file_entry_get_utf16_name_size( |
2944 | | libewf_lef_file_entry_t *lef_file_entry, |
2945 | | size_t *utf16_string_size, |
2946 | | libcerror_error_t **error ) |
2947 | 0 | { |
2948 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_name_size"; |
2949 | 0 | size_t safe_utf16_string_size = 0; |
2950 | |
|
2951 | 0 | if( lef_file_entry == NULL ) |
2952 | 0 | { |
2953 | 0 | libcerror_error_set( |
2954 | 0 | error, |
2955 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2956 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2957 | 0 | "%s: invalid file entry.", |
2958 | 0 | function ); |
2959 | |
|
2960 | 0 | return( -1 ); |
2961 | 0 | } |
2962 | 0 | if( utf16_string_size == NULL ) |
2963 | 0 | { |
2964 | 0 | libcerror_error_set( |
2965 | 0 | error, |
2966 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2967 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2968 | 0 | "%s: invalid UTF-16 string size.", |
2969 | 0 | function ); |
2970 | |
|
2971 | 0 | return( -1 ); |
2972 | 0 | } |
2973 | 0 | if( ( lef_file_entry->name_data != NULL ) |
2974 | 0 | && ( lef_file_entry->name_data_size > 0 ) ) |
2975 | 0 | { |
2976 | 0 | if( libuna_utf16_string_size_from_utf16_stream( |
2977 | 0 | lef_file_entry->name_data, |
2978 | 0 | lef_file_entry->name_data_size, |
2979 | 0 | LIBUNA_ENDIAN_LITTLE | LIBUNA_UTF16_STREAM_ALLOW_UNPAIRED_SURROGATE, |
2980 | 0 | &safe_utf16_string_size, |
2981 | 0 | error ) != 1 ) |
2982 | 0 | { |
2983 | 0 | libcerror_error_set( |
2984 | 0 | error, |
2985 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2986 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2987 | 0 | "%s: unable to retrieve UTF-16 string size.", |
2988 | 0 | function ); |
2989 | |
|
2990 | 0 | return( -1 ); |
2991 | 0 | } |
2992 | 0 | } |
2993 | 0 | *utf16_string_size = safe_utf16_string_size; |
2994 | |
|
2995 | 0 | return( 1 ); |
2996 | 0 | } |
2997 | | |
2998 | | /* Retrieves the UTF-16 encoded name value |
2999 | | * This function uses UCS-2 (with surrogates) to support characters outside Unicode |
3000 | | * The size should include the end of string character |
3001 | | * Returns 1 if successful or -1 on error |
3002 | | */ |
3003 | | int libewf_lef_file_entry_get_utf16_name( |
3004 | | libewf_lef_file_entry_t *lef_file_entry, |
3005 | | uint16_t *utf16_string, |
3006 | | size_t utf16_string_size, |
3007 | | libcerror_error_t **error ) |
3008 | 0 | { |
3009 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_name"; |
3010 | |
|
3011 | 0 | if( lef_file_entry == NULL ) |
3012 | 0 | { |
3013 | 0 | libcerror_error_set( |
3014 | 0 | error, |
3015 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3016 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3017 | 0 | "%s: invalid file entry.", |
3018 | 0 | function ); |
3019 | |
|
3020 | 0 | return( -1 ); |
3021 | 0 | } |
3022 | 0 | if( libuna_utf16_string_copy_from_utf16_stream( |
3023 | 0 | utf16_string, |
3024 | 0 | utf16_string_size, |
3025 | 0 | lef_file_entry->name_data, |
3026 | 0 | lef_file_entry->name_data_size, |
3027 | 0 | LIBUNA_ENDIAN_LITTLE | LIBUNA_UTF16_STREAM_ALLOW_UNPAIRED_SURROGATE, |
3028 | 0 | error ) != 1 ) |
3029 | 0 | { |
3030 | 0 | libcerror_error_set( |
3031 | 0 | error, |
3032 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3033 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3034 | 0 | "%s: unable to retrieve UTF-16 string.", |
3035 | 0 | function ); |
3036 | |
|
3037 | 0 | return( -1 ); |
3038 | 0 | } |
3039 | 0 | return( 1 ); |
3040 | 0 | } |
3041 | | |
3042 | | /* Compares an UTF-16 string with a file entry name |
3043 | | * Returns LIBUNA_COMPARE_LESS, LIBUNA_COMPARE_EQUAL, LIBUNA_COMPARE_GREATER if successful or -1 on error |
3044 | | */ |
3045 | | int libewf_lef_file_entry_compare_name_with_utf16_string( |
3046 | | libewf_lef_file_entry_t *lef_file_entry, |
3047 | | const uint16_t *utf16_string, |
3048 | | size_t utf16_string_length, |
3049 | | libcerror_error_t **error ) |
3050 | 0 | { |
3051 | 0 | static char *function = "libewf_lef_file_entry_compare_name_with_utf16_string"; |
3052 | 0 | int result = 0; |
3053 | |
|
3054 | 0 | if( lef_file_entry == NULL ) |
3055 | 0 | { |
3056 | 0 | libcerror_error_set( |
3057 | 0 | error, |
3058 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3059 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3060 | 0 | "%s: invalid file entry.", |
3061 | 0 | function ); |
3062 | |
|
3063 | 0 | return( -1 ); |
3064 | 0 | } |
3065 | 0 | result = libuna_utf16_string_compare_with_utf16_stream( |
3066 | 0 | utf16_string, |
3067 | 0 | utf16_string_length, |
3068 | 0 | lef_file_entry->name_data, |
3069 | 0 | lef_file_entry->name_data_size, |
3070 | 0 | LIBUNA_ENDIAN_LITTLE | LIBUNA_UTF16_STREAM_ALLOW_UNPAIRED_SURROGATE, |
3071 | 0 | error ); |
3072 | |
|
3073 | 0 | if( result == -1 ) |
3074 | 0 | { |
3075 | 0 | libcerror_error_set( |
3076 | 0 | error, |
3077 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3078 | 0 | LIBCERROR_RUNTIME_ERROR_GENERIC, |
3079 | 0 | "%s: unable to compare name with UTF-16 string.", |
3080 | 0 | function ); |
3081 | |
|
3082 | 0 | return( -1 ); |
3083 | 0 | } |
3084 | 0 | return( result ); |
3085 | 0 | } |
3086 | | |
3087 | | /* Retrieves the size of the UTF-8 encoded short name |
3088 | | * The returned size includes the end of string character |
3089 | | * Returns 1 if successful or -1 on error |
3090 | | */ |
3091 | | int libewf_lef_file_entry_get_utf8_short_name_size( |
3092 | | libewf_lef_file_entry_t *lef_file_entry, |
3093 | | size_t *utf8_string_size, |
3094 | | libcerror_error_t **error ) |
3095 | 0 | { |
3096 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_short_name_size"; |
3097 | 0 | int result = 0; |
3098 | |
|
3099 | 0 | if( lef_file_entry == NULL ) |
3100 | 0 | { |
3101 | 0 | libcerror_error_set( |
3102 | 0 | error, |
3103 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3104 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3105 | 0 | "%s: invalid file entry.", |
3106 | 0 | function ); |
3107 | |
|
3108 | 0 | return( -1 ); |
3109 | 0 | } |
3110 | 0 | result = libewf_serialized_string_get_utf8_string_size( |
3111 | 0 | lef_file_entry->short_name, |
3112 | 0 | utf8_string_size, |
3113 | 0 | error ); |
3114 | |
|
3115 | 0 | if( result == -1 ) |
3116 | 0 | { |
3117 | 0 | libcerror_error_set( |
3118 | 0 | error, |
3119 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3120 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3121 | 0 | "%s: unable to retrieve short name UTF-8 string size.", |
3122 | 0 | function ); |
3123 | |
|
3124 | 0 | return( -1 ); |
3125 | 0 | } |
3126 | 0 | return( 1 ); |
3127 | 0 | } |
3128 | | |
3129 | | /* Retrieves the UTF-8 encoded short name value |
3130 | | * The size should include the end of string character |
3131 | | * Returns 1 if successful or -1 on error |
3132 | | */ |
3133 | | int libewf_lef_file_entry_get_utf8_short_name( |
3134 | | libewf_lef_file_entry_t *lef_file_entry, |
3135 | | uint8_t *utf8_string, |
3136 | | size_t utf8_string_size, |
3137 | | libcerror_error_t **error ) |
3138 | 0 | { |
3139 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_short_name"; |
3140 | 0 | int result = 0; |
3141 | |
|
3142 | 0 | if( lef_file_entry == NULL ) |
3143 | 0 | { |
3144 | 0 | libcerror_error_set( |
3145 | 0 | error, |
3146 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3147 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3148 | 0 | "%s: invalid file entry.", |
3149 | 0 | function ); |
3150 | |
|
3151 | 0 | return( -1 ); |
3152 | 0 | } |
3153 | 0 | result = libewf_serialized_string_get_utf8_string( |
3154 | 0 | lef_file_entry->short_name, |
3155 | 0 | utf8_string, |
3156 | 0 | utf8_string_size, |
3157 | 0 | error ); |
3158 | |
|
3159 | 0 | if( result == -1 ) |
3160 | 0 | { |
3161 | 0 | libcerror_error_set( |
3162 | 0 | error, |
3163 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3164 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3165 | 0 | "%s: unable to copy short name to UTF-8 string.", |
3166 | 0 | function ); |
3167 | |
|
3168 | 0 | return( -1 ); |
3169 | 0 | } |
3170 | 0 | return( 1 ); |
3171 | 0 | } |
3172 | | |
3173 | | /* Retrieves the size of the UTF-16 encoded short name |
3174 | | * The returned size includes the end of string character |
3175 | | * Returns 1 if successful or -1 on error |
3176 | | */ |
3177 | | int libewf_lef_file_entry_get_utf16_short_name_size( |
3178 | | libewf_lef_file_entry_t *lef_file_entry, |
3179 | | size_t *utf16_string_size, |
3180 | | libcerror_error_t **error ) |
3181 | 0 | { |
3182 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_short_name_size"; |
3183 | 0 | int result = 0; |
3184 | |
|
3185 | 0 | if( lef_file_entry == NULL ) |
3186 | 0 | { |
3187 | 0 | libcerror_error_set( |
3188 | 0 | error, |
3189 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3190 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3191 | 0 | "%s: invalid file entry.", |
3192 | 0 | function ); |
3193 | |
|
3194 | 0 | return( -1 ); |
3195 | 0 | } |
3196 | 0 | result = libewf_serialized_string_get_utf16_string_size( |
3197 | 0 | lef_file_entry->short_name, |
3198 | 0 | utf16_string_size, |
3199 | 0 | error ); |
3200 | |
|
3201 | 0 | if( result == -1 ) |
3202 | 0 | { |
3203 | 0 | libcerror_error_set( |
3204 | 0 | error, |
3205 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3206 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3207 | 0 | "%s: unable to retrieve short name UTF-16 string size.", |
3208 | 0 | function ); |
3209 | |
|
3210 | 0 | return( -1 ); |
3211 | 0 | } |
3212 | 0 | return( 1 ); |
3213 | 0 | } |
3214 | | |
3215 | | /* Retrieves the UTF-16 encoded short name value |
3216 | | * The size should include the end of string character |
3217 | | * Returns 1 if successful or -1 on error |
3218 | | */ |
3219 | | int libewf_lef_file_entry_get_utf16_short_name( |
3220 | | libewf_lef_file_entry_t *lef_file_entry, |
3221 | | uint16_t *utf16_string, |
3222 | | size_t utf16_string_size, |
3223 | | libcerror_error_t **error ) |
3224 | 0 | { |
3225 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_short_name"; |
3226 | 0 | int result = 0; |
3227 | |
|
3228 | 0 | if( lef_file_entry == NULL ) |
3229 | 0 | { |
3230 | 0 | libcerror_error_set( |
3231 | 0 | error, |
3232 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3233 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3234 | 0 | "%s: invalid file entry.", |
3235 | 0 | function ); |
3236 | |
|
3237 | 0 | return( -1 ); |
3238 | 0 | } |
3239 | 0 | result = libewf_serialized_string_get_utf16_string( |
3240 | 0 | lef_file_entry->short_name, |
3241 | 0 | utf16_string, |
3242 | 0 | utf16_string_size, |
3243 | 0 | error ); |
3244 | |
|
3245 | 0 | if( result == -1 ) |
3246 | 0 | { |
3247 | 0 | libcerror_error_set( |
3248 | 0 | error, |
3249 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3250 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3251 | 0 | "%s: unable to copy short name to UTF-16 string.", |
3252 | 0 | function ); |
3253 | |
|
3254 | 0 | return( -1 ); |
3255 | 0 | } |
3256 | 0 | return( 1 ); |
3257 | 0 | } |
3258 | | |
3259 | | /* Retrieves the size |
3260 | | * Returns 1 if successful or -1 on error |
3261 | | */ |
3262 | | int libewf_lef_file_entry_get_size( |
3263 | | libewf_lef_file_entry_t *lef_file_entry, |
3264 | | size64_t *size, |
3265 | | libcerror_error_t **error ) |
3266 | 0 | { |
3267 | 0 | static char *function = "libewf_lef_file_entry_get_size"; |
3268 | |
|
3269 | 0 | if( lef_file_entry == NULL ) |
3270 | 0 | { |
3271 | 0 | libcerror_error_set( |
3272 | 0 | error, |
3273 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3274 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3275 | 0 | "%s: invalid file entry.", |
3276 | 0 | function ); |
3277 | |
|
3278 | 0 | return( -1 ); |
3279 | 0 | } |
3280 | 0 | if( size == NULL ) |
3281 | 0 | { |
3282 | 0 | libcerror_error_set( |
3283 | 0 | error, |
3284 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3285 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3286 | 0 | "%s: invalid size.", |
3287 | 0 | function ); |
3288 | |
|
3289 | 0 | return( -1 ); |
3290 | 0 | } |
3291 | 0 | *size = lef_file_entry->size; |
3292 | |
|
3293 | 0 | return( 1 ); |
3294 | 0 | } |
3295 | | |
3296 | | /* Retrieves the source identifier |
3297 | | * Returns 1 if successful or -1 on error |
3298 | | */ |
3299 | | int libewf_lef_file_entry_get_source_identifier( |
3300 | | libewf_lef_file_entry_t *lef_file_entry, |
3301 | | int *source_identifier, |
3302 | | libcerror_error_t **error ) |
3303 | 0 | { |
3304 | 0 | static char *function = "libewf_lef_file_entry_get_source_identifier"; |
3305 | |
|
3306 | 0 | if( lef_file_entry == NULL ) |
3307 | 0 | { |
3308 | 0 | libcerror_error_set( |
3309 | 0 | error, |
3310 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3311 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3312 | 0 | "%s: invalid file entry.", |
3313 | 0 | function ); |
3314 | |
|
3315 | 0 | return( -1 ); |
3316 | 0 | } |
3317 | 0 | if( source_identifier == NULL ) |
3318 | 0 | { |
3319 | 0 | libcerror_error_set( |
3320 | 0 | error, |
3321 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3322 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3323 | 0 | "%s: invalid source identifier.", |
3324 | 0 | function ); |
3325 | |
|
3326 | 0 | return( -1 ); |
3327 | 0 | } |
3328 | 0 | *source_identifier = lef_file_entry->source_identifier; |
3329 | |
|
3330 | 0 | return( 1 ); |
3331 | 0 | } |
3332 | | |
3333 | | /* Retrieves the permission group index |
3334 | | * Returns 1 if successful or -1 on error |
3335 | | */ |
3336 | | int libewf_lef_file_entry_get_permission_group_index( |
3337 | | libewf_lef_file_entry_t *lef_file_entry, |
3338 | | int *permission_group_index, |
3339 | | libcerror_error_t **error ) |
3340 | 0 | { |
3341 | 0 | static char *function = "libewf_lef_file_entry_get_permission_group_index"; |
3342 | |
|
3343 | 0 | if( lef_file_entry == NULL ) |
3344 | 0 | { |
3345 | 0 | libcerror_error_set( |
3346 | 0 | error, |
3347 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3348 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3349 | 0 | "%s: invalid file entry.", |
3350 | 0 | function ); |
3351 | |
|
3352 | 0 | return( -1 ); |
3353 | 0 | } |
3354 | 0 | if( permission_group_index == NULL ) |
3355 | 0 | { |
3356 | 0 | libcerror_error_set( |
3357 | 0 | error, |
3358 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3359 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3360 | 0 | "%s: invalid permission group index.", |
3361 | 0 | function ); |
3362 | |
|
3363 | 0 | return( -1 ); |
3364 | 0 | } |
3365 | 0 | *permission_group_index = lef_file_entry->permission_group_index; |
3366 | |
|
3367 | 0 | return( 1 ); |
3368 | 0 | } |
3369 | | |
3370 | | /* Retrieves the record type |
3371 | | * Returns 1 if successful or -1 on error |
3372 | | */ |
3373 | | int libewf_lef_file_entry_get_record_type( |
3374 | | libewf_lef_file_entry_t *lef_file_entry, |
3375 | | uint32_t *record_type, |
3376 | | libcerror_error_t **error ) |
3377 | 0 | { |
3378 | 0 | static char *function = "libewf_lef_file_entry_get_record_type"; |
3379 | |
|
3380 | 0 | if( lef_file_entry == NULL ) |
3381 | 0 | { |
3382 | 0 | libcerror_error_set( |
3383 | 0 | error, |
3384 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3385 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3386 | 0 | "%s: invalid file entry.", |
3387 | 0 | function ); |
3388 | |
|
3389 | 0 | return( -1 ); |
3390 | 0 | } |
3391 | 0 | if( record_type == NULL ) |
3392 | 0 | { |
3393 | 0 | libcerror_error_set( |
3394 | 0 | error, |
3395 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3396 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3397 | 0 | "%s: invalid record type.", |
3398 | 0 | function ); |
3399 | |
|
3400 | 0 | return( -1 ); |
3401 | 0 | } |
3402 | 0 | *record_type = lef_file_entry->record_type; |
3403 | |
|
3404 | 0 | return( 1 ); |
3405 | 0 | } |
3406 | | |
3407 | | /* Retrieves the creation date and time |
3408 | | * Returns 1 if successful, 0 if not set or -1 on error |
3409 | | */ |
3410 | | int libewf_lef_file_entry_get_creation_time( |
3411 | | libewf_lef_file_entry_t *lef_file_entry, |
3412 | | int64_t *posix_time, |
3413 | | libcerror_error_t **error ) |
3414 | 0 | { |
3415 | 0 | static char *function = "libewf_lef_file_entry_get_creation_time"; |
3416 | |
|
3417 | 0 | if( lef_file_entry == NULL ) |
3418 | 0 | { |
3419 | 0 | libcerror_error_set( |
3420 | 0 | error, |
3421 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3422 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3423 | 0 | "%s: invalid file entry.", |
3424 | 0 | function ); |
3425 | |
|
3426 | 0 | return( -1 ); |
3427 | 0 | } |
3428 | 0 | if( posix_time == NULL ) |
3429 | 0 | { |
3430 | 0 | libcerror_error_set( |
3431 | 0 | error, |
3432 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3433 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3434 | 0 | "%s: invalid POSIX time.", |
3435 | 0 | function ); |
3436 | |
|
3437 | 0 | return( -1 ); |
3438 | 0 | } |
3439 | 0 | *posix_time = lef_file_entry->creation_time; |
3440 | |
|
3441 | 0 | return( 1 ); |
3442 | 0 | } |
3443 | | |
3444 | | /* Retrieves the (file) modification (last written) date and time |
3445 | | * Returns 1 if successful, 0 if not set or -1 on error |
3446 | | */ |
3447 | | int libewf_lef_file_entry_get_modification_time( |
3448 | | libewf_lef_file_entry_t *lef_file_entry, |
3449 | | int64_t *posix_time, |
3450 | | libcerror_error_t **error ) |
3451 | 0 | { |
3452 | 0 | static char *function = "libewf_lef_file_entry_get_modification_time"; |
3453 | |
|
3454 | 0 | if( lef_file_entry == NULL ) |
3455 | 0 | { |
3456 | 0 | libcerror_error_set( |
3457 | 0 | error, |
3458 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3459 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3460 | 0 | "%s: invalid file entry.", |
3461 | 0 | function ); |
3462 | |
|
3463 | 0 | return( -1 ); |
3464 | 0 | } |
3465 | 0 | if( posix_time == NULL ) |
3466 | 0 | { |
3467 | 0 | libcerror_error_set( |
3468 | 0 | error, |
3469 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3470 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3471 | 0 | "%s: invalid POSIX time.", |
3472 | 0 | function ); |
3473 | |
|
3474 | 0 | return( -1 ); |
3475 | 0 | } |
3476 | 0 | *posix_time = lef_file_entry->modification_time; |
3477 | |
|
3478 | 0 | return( 1 ); |
3479 | 0 | } |
3480 | | |
3481 | | /* Retrieves the access date and time |
3482 | | * Returns 1 if successful, 0 if not set or -1 on error |
3483 | | */ |
3484 | | int libewf_lef_file_entry_get_access_time( |
3485 | | libewf_lef_file_entry_t *lef_file_entry, |
3486 | | int64_t *posix_time, |
3487 | | libcerror_error_t **error ) |
3488 | 0 | { |
3489 | 0 | static char *function = "libewf_lef_file_entry_get_access_time"; |
3490 | |
|
3491 | 0 | if( lef_file_entry == NULL ) |
3492 | 0 | { |
3493 | 0 | libcerror_error_set( |
3494 | 0 | error, |
3495 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3496 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3497 | 0 | "%s: invalid file entry.", |
3498 | 0 | function ); |
3499 | |
|
3500 | 0 | return( -1 ); |
3501 | 0 | } |
3502 | 0 | if( posix_time == NULL ) |
3503 | 0 | { |
3504 | 0 | libcerror_error_set( |
3505 | 0 | error, |
3506 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3507 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3508 | 0 | "%s: invalid POSIX time.", |
3509 | 0 | function ); |
3510 | |
|
3511 | 0 | return( -1 ); |
3512 | 0 | } |
3513 | 0 | *posix_time = lef_file_entry->access_time; |
3514 | |
|
3515 | 0 | return( 1 ); |
3516 | 0 | } |
3517 | | |
3518 | | /* Retrieves the (file system entry) modification date and time |
3519 | | * Returns 1 if successful, 0 if not set or -1 on error |
3520 | | */ |
3521 | | int libewf_lef_file_entry_get_entry_modification_time( |
3522 | | libewf_lef_file_entry_t *lef_file_entry, |
3523 | | int64_t *posix_time, |
3524 | | libcerror_error_t **error ) |
3525 | 0 | { |
3526 | 0 | static char *function = "libewf_lef_file_entry_get_entry_modification_time"; |
3527 | |
|
3528 | 0 | if( lef_file_entry == NULL ) |
3529 | 0 | { |
3530 | 0 | libcerror_error_set( |
3531 | 0 | error, |
3532 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3533 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3534 | 0 | "%s: invalid file entry.", |
3535 | 0 | function ); |
3536 | |
|
3537 | 0 | return( -1 ); |
3538 | 0 | } |
3539 | 0 | if( posix_time == NULL ) |
3540 | 0 | { |
3541 | 0 | libcerror_error_set( |
3542 | 0 | error, |
3543 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3544 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3545 | 0 | "%s: invalid POSIX time.", |
3546 | 0 | function ); |
3547 | |
|
3548 | 0 | return( -1 ); |
3549 | 0 | } |
3550 | 0 | *posix_time = lef_file_entry->entry_modification_time; |
3551 | |
|
3552 | 0 | return( 1 ); |
3553 | 0 | } |
3554 | | |
3555 | | /* Retrieves the deletion date and time |
3556 | | * Returns 1 if successful, 0 if not set or -1 on error |
3557 | | */ |
3558 | | int libewf_lef_file_entry_get_deletion_time( |
3559 | | libewf_lef_file_entry_t *lef_file_entry, |
3560 | | int64_t *posix_time, |
3561 | | libcerror_error_t **error ) |
3562 | 0 | { |
3563 | 0 | static char *function = "libewf_lef_file_entry_get_deletion_time"; |
3564 | |
|
3565 | 0 | if( lef_file_entry == NULL ) |
3566 | 0 | { |
3567 | 0 | libcerror_error_set( |
3568 | 0 | error, |
3569 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3570 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3571 | 0 | "%s: invalid file entry.", |
3572 | 0 | function ); |
3573 | |
|
3574 | 0 | return( -1 ); |
3575 | 0 | } |
3576 | 0 | if( posix_time == NULL ) |
3577 | 0 | { |
3578 | 0 | libcerror_error_set( |
3579 | 0 | error, |
3580 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3581 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3582 | 0 | "%s: invalid POSIX time.", |
3583 | 0 | function ); |
3584 | |
|
3585 | 0 | return( -1 ); |
3586 | 0 | } |
3587 | 0 | *posix_time = lef_file_entry->deletion_time; |
3588 | |
|
3589 | 0 | return( 1 ); |
3590 | 0 | } |
3591 | | |
3592 | | /* Retrieves the UTF-8 encoded MD5 hash value |
3593 | | * Returns 1 if successful, 0 if not set or -1 on error |
3594 | | */ |
3595 | | int libewf_lef_file_entry_get_utf8_hash_value_md5( |
3596 | | libewf_lef_file_entry_t *lef_file_entry, |
3597 | | uint8_t *utf8_string, |
3598 | | size_t utf8_string_size, |
3599 | | libcerror_error_t **error ) |
3600 | 0 | { |
3601 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_hash_value_md5"; |
3602 | 0 | int result = 0; |
3603 | |
|
3604 | 0 | if( lef_file_entry == NULL ) |
3605 | 0 | { |
3606 | 0 | libcerror_error_set( |
3607 | 0 | error, |
3608 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3609 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3610 | 0 | "%s: invalid file entry.", |
3611 | 0 | function ); |
3612 | |
|
3613 | 0 | return( -1 ); |
3614 | 0 | } |
3615 | 0 | result = libewf_serialized_string_get_utf8_string( |
3616 | 0 | lef_file_entry->md5_hash, |
3617 | 0 | utf8_string, |
3618 | 0 | utf8_string_size, |
3619 | 0 | error ); |
3620 | |
|
3621 | 0 | if( result == -1 ) |
3622 | 0 | { |
3623 | 0 | libcerror_error_set( |
3624 | 0 | error, |
3625 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3626 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3627 | 0 | "%s: unable to copy MD5 hash to UTF-8 string.", |
3628 | 0 | function ); |
3629 | |
|
3630 | 0 | return( -1 ); |
3631 | 0 | } |
3632 | 0 | return( result ); |
3633 | 0 | } |
3634 | | |
3635 | | /* Retrieves the UTF-16 encoded MD5 hash value |
3636 | | * Returns 1 if successful, 0 if not set or -1 on error |
3637 | | */ |
3638 | | int libewf_lef_file_entry_get_utf16_hash_value_md5( |
3639 | | libewf_lef_file_entry_t *lef_file_entry, |
3640 | | uint16_t *utf16_string, |
3641 | | size_t utf16_string_size, |
3642 | | libcerror_error_t **error ) |
3643 | 0 | { |
3644 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_hash_value_md5"; |
3645 | 0 | int result = 0; |
3646 | |
|
3647 | 0 | if( lef_file_entry == NULL ) |
3648 | 0 | { |
3649 | 0 | libcerror_error_set( |
3650 | 0 | error, |
3651 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3652 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3653 | 0 | "%s: invalid file entry.", |
3654 | 0 | function ); |
3655 | |
|
3656 | 0 | return( -1 ); |
3657 | 0 | } |
3658 | 0 | result = libewf_serialized_string_get_utf16_string( |
3659 | 0 | lef_file_entry->md5_hash, |
3660 | 0 | utf16_string, |
3661 | 0 | utf16_string_size, |
3662 | 0 | error ); |
3663 | |
|
3664 | 0 | if( result == -1 ) |
3665 | 0 | { |
3666 | 0 | libcerror_error_set( |
3667 | 0 | error, |
3668 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3669 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3670 | 0 | "%s: unable to copy MD5 hash to UTF-16 string.", |
3671 | 0 | function ); |
3672 | |
|
3673 | 0 | return( -1 ); |
3674 | 0 | } |
3675 | 0 | return( result ); |
3676 | 0 | } |
3677 | | |
3678 | | /* Retrieves the UTF-8 encoded SHA1 hash value |
3679 | | * Returns 1 if successful, 0 if not set or -1 on error |
3680 | | */ |
3681 | | int libewf_lef_file_entry_get_utf8_hash_value_sha1( |
3682 | | libewf_lef_file_entry_t *lef_file_entry, |
3683 | | uint8_t *utf8_string, |
3684 | | size_t utf8_string_size, |
3685 | | libcerror_error_t **error ) |
3686 | 0 | { |
3687 | 0 | static char *function = "libewf_lef_file_entry_get_utf8_hash_value_sha1"; |
3688 | 0 | int result = 0; |
3689 | |
|
3690 | 0 | if( lef_file_entry == NULL ) |
3691 | 0 | { |
3692 | 0 | libcerror_error_set( |
3693 | 0 | error, |
3694 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3695 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3696 | 0 | "%s: invalid file entry.", |
3697 | 0 | function ); |
3698 | |
|
3699 | 0 | return( -1 ); |
3700 | 0 | } |
3701 | 0 | result = libewf_serialized_string_get_utf8_string( |
3702 | 0 | lef_file_entry->sha1_hash, |
3703 | 0 | utf8_string, |
3704 | 0 | utf8_string_size, |
3705 | 0 | error ); |
3706 | |
|
3707 | 0 | if( result == -1 ) |
3708 | 0 | { |
3709 | 0 | libcerror_error_set( |
3710 | 0 | error, |
3711 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3712 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3713 | 0 | "%s: unable to copy SHA1 hash to UTF-8 string.", |
3714 | 0 | function ); |
3715 | |
|
3716 | 0 | return( -1 ); |
3717 | 0 | } |
3718 | 0 | return( result ); |
3719 | 0 | } |
3720 | | |
3721 | | /* Retrieves the UTF-16 encoded SHA1 hash value |
3722 | | * Returns 1 if successful, 0 if not set or -1 on error |
3723 | | */ |
3724 | | int libewf_lef_file_entry_get_utf16_hash_value_sha1( |
3725 | | libewf_lef_file_entry_t *lef_file_entry, |
3726 | | uint16_t *utf16_string, |
3727 | | size_t utf16_string_size, |
3728 | | libcerror_error_t **error ) |
3729 | 0 | { |
3730 | 0 | static char *function = "libewf_lef_file_entry_get_utf16_hash_value_sha1"; |
3731 | 0 | int result = 0; |
3732 | |
|
3733 | 0 | if( lef_file_entry == NULL ) |
3734 | 0 | { |
3735 | 0 | libcerror_error_set( |
3736 | 0 | error, |
3737 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3738 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3739 | 0 | "%s: invalid file entry.", |
3740 | 0 | function ); |
3741 | |
|
3742 | 0 | return( -1 ); |
3743 | 0 | } |
3744 | 0 | result = libewf_serialized_string_get_utf16_string( |
3745 | 0 | lef_file_entry->sha1_hash, |
3746 | 0 | utf16_string, |
3747 | 0 | utf16_string_size, |
3748 | 0 | error ); |
3749 | |
|
3750 | 0 | if( result == -1 ) |
3751 | 0 | { |
3752 | 0 | libcerror_error_set( |
3753 | 0 | error, |
3754 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3755 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3756 | 0 | "%s: unable to copy SHA1 hash to UTF-16 string.", |
3757 | 0 | function ); |
3758 | |
|
3759 | 0 | return( -1 ); |
3760 | 0 | } |
3761 | 0 | return( result ); |
3762 | 0 | } |
3763 | | |
3764 | | /* Retrieves the number of extended attributes |
3765 | | * Returns 1 if successful or -1 on error |
3766 | | */ |
3767 | | int libewf_lef_file_entry_get_number_of_extended_attributes( |
3768 | | libewf_lef_file_entry_t *lef_file_entry, |
3769 | | int *number_of_extended_attributes, |
3770 | | libcerror_error_t **error ) |
3771 | 0 | { |
3772 | 0 | static char *function = "libewf_lef_file_entry_get_number_of_extended_attributes"; |
3773 | |
|
3774 | 0 | if( lef_file_entry == NULL ) |
3775 | 0 | { |
3776 | 0 | libcerror_error_set( |
3777 | 0 | error, |
3778 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3779 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3780 | 0 | "%s: invalid file entry.", |
3781 | 0 | function ); |
3782 | |
|
3783 | 0 | return( -1 ); |
3784 | 0 | } |
3785 | 0 | if( libcdata_array_get_number_of_entries( |
3786 | 0 | lef_file_entry->extended_attributes, |
3787 | 0 | number_of_extended_attributes, |
3788 | 0 | error ) != 1 ) |
3789 | 0 | { |
3790 | 0 | libcerror_error_set( |
3791 | 0 | error, |
3792 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3793 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3794 | 0 | "%s: unable to retrieve number of entries from extended attributes array.", |
3795 | 0 | function ); |
3796 | |
|
3797 | 0 | return( -1 ); |
3798 | 0 | } |
3799 | 0 | return( 1 ); |
3800 | 0 | } |
3801 | | |
3802 | | /* Retrieves a specific extended attribute from the group |
3803 | | * Returns 1 if successful or -1 on error |
3804 | | */ |
3805 | | int libewf_lef_file_entry_get_extended_attribute_by_index( |
3806 | | libewf_lef_file_entry_t *lef_file_entry, |
3807 | | int extended_attribute_index, |
3808 | | libewf_lef_extended_attribute_t **lef_extended_attribute, |
3809 | | libcerror_error_t **error ) |
3810 | 0 | { |
3811 | 0 | static char *function = "libewf_lef_file_entry_get_extended_attribute_by_index"; |
3812 | |
|
3813 | 0 | if( lef_file_entry == NULL ) |
3814 | 0 | { |
3815 | 0 | libcerror_error_set( |
3816 | 0 | error, |
3817 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3818 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3819 | 0 | "%s: invalid file entry.", |
3820 | 0 | function ); |
3821 | |
|
3822 | 0 | return( -1 ); |
3823 | 0 | } |
3824 | 0 | if( libcdata_array_get_entry_by_index( |
3825 | 0 | lef_file_entry->extended_attributes, |
3826 | 0 | extended_attribute_index, |
3827 | 0 | (intptr_t **) lef_extended_attribute, |
3828 | 0 | error ) != 1 ) |
3829 | 0 | { |
3830 | 0 | libcerror_error_set( |
3831 | 0 | error, |
3832 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3833 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3834 | 0 | "%s: unable to retrieve entry: %d from extended attributes array.", |
3835 | 0 | function, |
3836 | 0 | extended_attribute_index ); |
3837 | |
|
3838 | 0 | return( -1 ); |
3839 | 0 | } |
3840 | 0 | return( 1 ); |
3841 | 0 | } |
3842 | | |