[lttng-dev] [RFC PATCH] Fix: consumerd(64/32)_lib_dir can be NULL

Jonathan Rajotte jonathan.rajotte-julien at efficios.com
Wed Nov 29 21:42:29 UTC 2017


Reproducer:
lttng-sessiond \
    --consumerd32-path=/usr/local/lib/lttng/libexec/lttng-consumerd \
    --consumerd64-path=/usr/local/lib/lttng/libexec/lttng-consumerd

lttng create
lttng enable-event -u -a

On a 64bit machine the invocation of the 64bit consumerd will not fail
since its libdir is populated by sessiond_config_init but will segfault on
spawning of the 32 bit consumerd when performing the check of libdir
value.

On a 32bit machine the opposite will happen.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
---

Another possibility would be to always initialize to an empty "" instead of
NULL.

---
 src/bin/lttng-sessiond/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index 3d0a65de..f921621b 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -2442,7 +2442,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
 		{
 			char *tmpnew = NULL;
 
-			if (config.consumerd64_lib_dir.value[0] != '\0') {
+			if (config.consumerd64_lib_dir.value && config.consumerd64_lib_dir.value[0] != '\0') {
 				char *tmp;
 				size_t tmplen;
 
@@ -2485,7 +2485,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
 		{
 			char *tmpnew = NULL;
 
-			if (config.consumerd32_lib_dir.value[0] != '\0') {
+			if (config.consumerd32_lib_dir.value && config.consumerd32_lib_dir.value[0] != '\0') {
 				char *tmp;
 				size_t tmplen;
 
-- 
2.11.0



More information about the lttng-dev mailing list