libyal / libewf

Libewf is a library to access the Expert Witness Compression Format (EWF)
GNU Lesser General Public License v3.0
263 stars 76 forks source link

libcthreads_read_write_lock_release_for_write overwriting result in libewf_internal_handle_open_file_io_pool #170

Closed taco-paco closed 2 years ago

taco-paco commented 2 years ago

Errors from libewf_internal_handle_open_file_io_pool get overwritten here. I made a fork with fixes if there're no objections/issues I can open upstream pr.

joachimmetz commented 2 years ago

How come that it is overwritten? Last time I checked, error_set just appends https://github.com/libyal/libcerror/blob/main/libcerror/libcerror_error.c#L362

taco-paco commented 2 years ago

If call libewf_internal_handle_open_file_io_pool results with error then variable result will be set to smth other then 1. Then inside if we set it to -1 but unlike in other cases we don't exit function. So when we reach call to libcthreads_read_write_lock_release_for_write which executes with success it will set result to valid value 1. As result we will exit function successfully with internal_handle->file_io_pool uninitialized which I think is incorrect behaviout

joachimmetz commented 2 years ago

Ah if that is the issue you're pointing out, that's a matter of not setting result by libcthreads_read_write_lock_release_for_write. I'll make the necessary changes.

joachimmetz commented 2 years ago

@taco-paco thx for flagging, changes in https://github.com/libyal/libewf/commit/3ba79a6b83b8e5c8b2a928a204cf8baa71d369d8