lttng-ctl: fix: lttng_data_pending confuses communication status
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 11 Sep 2019 16:18:15 +0000 (12:18 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 26 Sep 2019 19:29:51 +0000 (15:29 -0400)
commit607d6ef9b5f7c57e72a1b4bfeb0ba7ff9fb4e613
tree9fb94819c61a89d7e5249d679739c0a91ddb6df1
parent3db6ba399d017418a91045284743fe5d55716d4a
lttng-ctl: fix: lttng_data_pending confuses communication status

lttng_ctl_ask_sessiond can return a positive value even though it
failed to receive the variable length payload of a session message
reply. In this case, lttng_ctl_ask_sessiond ends up calling into
lttng_ctl_ask_sessiond_fds_varlen() which will return the (negated)
error code returned by the session daemon if it was not LTTNG_OK.

The peer could return anything here, which lttng_data_pending will end
up interpreting as the length of the variable data that was received.

In this case, if the sessiond returns '-1', '1' will be returned to
lttng_data_pending, which it will interpret as being the length of the
'data_pending' byte flag. It will then dereference 'pending', which is
NULL, and (most likely) crash.

Check for NULL on top of checking for the return code. This
communication layer needs love as much as it needs a bulldozer.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/lib/lttng-ctl/lttng-ctl.c
This page took 0.024513 seconds and 4 git commands to generate.