Fix: relayd: unchecked allocation result of unlinked file pool
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 6 Apr 2020 16:39:17 +0000 (12:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 6 Apr 2020 16:39:17 +0000 (12:39 -0400)
`pool` is not checked for NULL after its allocation. Error out
if the allocation fails.

In lttng_unlinked_file_pool_create: Return value of function which
returns null is dereferenced without checking (CWE-476)

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

src/common/fd-tracker/inode.c

index 82799aee7e5fdcd107b89345c8c00d8e04c97f95..f105f5bd334df020e3d4800257ca3c0690f072eb 100644 (file)
@@ -250,6 +250,10 @@ LTTNG_HIDDEN struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
 {
        struct lttng_unlinked_file_pool *pool = zmalloc(sizeof(*pool));
 
+       if (!pool) {
+               goto error;
+       }
+
        if (!path || *path != '/') {
                ERR("Unlinked file pool must be created with an absolute path, path = \"%s\"",
                                path ? path : "NULL");
This page took 0.026261 seconds and 4 git commands to generate.