Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/hash_index: fix fd handling of r_hash_index_open()
So far, r_hash_index_open() expected that the ownership of the provided file descriptor should be handed over to the created RaucHashIndex which will close it then during autofree handling. However, this logic is error-prone since the caller has to know exactly when it still needs to close the fd and when it may not touch it anymore. This resulted in wrong fd handling in generate_adaptive_data() error cases and a double-close on the fd. This was wrong anyway but results in a critical error in RAUC since glib version 2.75.0 which comes with a pickier g_close() handling: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2964 | (rauc:818): GLib-CRITICAL **: 13:33:51.290: g_close(fd:3) failed with EBADF. The tracking of file descriptors got messed up Fix this by letting `r_hash_index_open()` dup the passed file descriptor. This way the caller and the hash index can handle their respective file descriptor independently. Simplify and fix the code by removing now unnecessary fd invalidations (data_fd = -1) and leveraging g_auto(filedesc). Signed-off-by: Enrico Joerns <[email protected]>
- Loading branch information