Fix: sessiond: crash when sending data_pending to an active session
[lttng-tools.git] / src / bin / lttng-sessiond / client.c
index a3d508a7018d5df82c0f0157ec7ba43fd1b5479a..fc26554c9583271474cd4b92fea99dc8f3573880 100644 (file)
@@ -1006,6 +1006,13 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock,
        bool need_domain;
        bool need_consumerd;
 
+       if (!lttcomm_sessiond_command_is_valid((enum lttcomm_sessiond_command) cmd_ctx->lsm.cmd_type)) {
+               ERR("Unknown client command received: command id = %" PRIu32,
+                               cmd_ctx->lsm.cmd_type);
+               ret = LTTNG_ERR_UND;
+               goto error;
+       }
+
        DBG("Processing client command '%s\' (%d)",
                lttcomm_sessiond_command_str(cmd_ctx->lsm.cmd_type),
                cmd_ctx->lsm.cmd_type);
@@ -1970,12 +1977,12 @@ skip_domain:
                         * ret will be set to LTTNG_OK at the end of
                         * this function.
                         */
-               } else if (pending_ret < 0) {
+               } else if (pending_ret <= LTTNG_OK || pending_ret >= LTTNG_ERR_NR) {
                        ret = LTTNG_ERR_UNK;
-                       goto setup_error;
+                       goto error;
                } else {
                        ret = pending_ret;
-                       goto setup_error;
+                       goto error;
                }
 
                pending_ret_byte = (uint8_t) pending_ret;
This page took 0.024164 seconds and 4 git commands to generate.