Fix: liblttng-ctl: unchecked return value on buffer append
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 21 Aug 2020 18:28:54 +0000 (14:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 21 Aug 2020 18:28:54 +0000 (14:28 -0400)
Allocation failures can cause lttng_dynamic_buffer_append to fail;
its result should always be checked.

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

src/lib/lttng-ctl/lttng-ctl.c

index 4eb36a2612d952bb71d38e9cedcc4d70a47d6148..3f1ab9fdc4bb8f17abe91345355b11f3263d61e2 100644 (file)
@@ -2970,7 +2970,11 @@ int lttng_register_trigger(struct lttng_trigger *trigger)
                goto end;
        }
 
-       lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm));
+       ret = lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm));
+       if (ret) {
+               ret = -LTTNG_ERR_NOMEM;
+               goto end;
+       }
 
        /*
         * This is needed to populate the trigger object size for the command
@@ -3030,7 +3034,11 @@ int lttng_unregister_trigger(struct lttng_trigger *trigger)
        memset(&lsm, 0, sizeof(lsm));
        lsm.cmd_type = LTTNG_UNREGISTER_TRIGGER;
 
-       lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm));
+       ret = lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm));
+       if (ret) {
+               ret = -LTTNG_ERR_NOMEM;
+               goto end;
+       }
 
        /*
         * This is needed to populate the trigger object size for the command
This page took 0.026486 seconds and 4 git commands to generate.