From c21e883d1f77555221a8a766a2141185d6681d26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 4 Oct 2021 12:41:51 -0400 Subject: [PATCH] Fix: userspace-probe: unreported error on string copy error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Issue ===== String copy errors, either due to the length or an allocation failure, are not reported by lttng_userspace_probe_location_tracepoint_create_from_payload and don't log a clear error message. This allowed truncation bugs like the one fixed in b45a296 to go unnoticed. Fix === Return an "invalid" status code and log a more descriptive error message. Signed-off-by: Jérémie Galarneau Change-Id: Ia07cac7cba315ea79337262e9082dd06eb60950f --- src/common/userspace-probe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/userspace-probe.c b/src/common/userspace-probe.c index 50795c59c..60bdddb48 100644 --- a/src/common/userspace-probe.c +++ b/src/common/userspace-probe.c @@ -1381,18 +1381,21 @@ int lttng_userspace_probe_location_tracepoint_create_from_payload( probe_name = lttng_strndup(probe_name_src, LTTNG_SYMBOL_NAME_LEN); if (!probe_name) { - PERROR("lttng_strndup"); + PERROR("Failed to allocate probe name"); + ret = -LTTNG_ERR_INVALID; goto end; } provider_name = lttng_strndup(provider_name_src, LTTNG_SYMBOL_NAME_LEN); if (!provider_name) { - PERROR("lttng_strndup"); + PERROR("Failed to allocate provider name"); + ret = -LTTNG_ERR_INVALID; goto end; } binary_path = lttng_strndup(binary_path_src, LTTNG_PATH_MAX); if (!binary_path) { - PERROR("lttng_strndup"); + PERROR("Failed to allocate binary path"); + ret = -LTTNG_ERR_INVALID; goto end; } -- 2.34.1