Fix: directory-handle: use of free'd handle on fstat() error
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 18 Feb 2020 01:13:49 +0000 (20:13 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 19 Feb 2020 22:47:41 +0000 (17:47 -0500)
On an error to fstat a directory handle, a directory handle is
released and is still initialized as if the error had not occurred.

Return NULL early from lttng_directory_handle_create_from_dirfd()
to prevent those erroneous accesses.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia2a3bb1cfe8c90d3f7f87a68286a9b8524694d3c

src/common/compat/directory-handle.c

index 9d2fed4637e453a67358049caaf6208505580c47..a790c5b79960d7933efe4221949070698b59eea9 100644 (file)
@@ -164,6 +164,8 @@ struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
                if (ret) {
                        PERROR("Failed to fstat directory file descriptor %i", dirfd);
                        lttng_directory_handle_release(&handle->ref);
+                       handle = NULL;
+                       goto end;
                }
        } else {
                handle->directory_inode = RESERVED_AT_FDCWD_INO;
This page took 0.026728 seconds and 4 git commands to generate.