From 97285430b75f44b6ce590e86cb9d996390e514c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 21 Aug 2020 14:28:54 -0400 Subject: [PATCH] Fix: liblttng-ctl: unchecked return value on buffer append MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/lib/lttng-ctl/lttng-ctl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 -- 2.34.1