From: Jérémie Galarneau Date: Fri, 21 Aug 2020 18:28:54 +0000 (-0400) Subject: Fix: liblttng-ctl: unchecked return value on buffer append X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=97285430b75f44b6ce590e86cb9d996390e514c8;ds=sidebyside Fix: liblttng-ctl: unchecked return value on buffer append Allocation failures can cause lttng_dynamic_buffer_append to fail; its result should always be checked. Signed-off-by: Jérémie Galarneau Change-Id: Id1870b1e19d3451afdd1e992355d83d4028b5723 --- diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 4eb36a261..3f1ab9fdc 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -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