From: Mathieu Desnoyers Date: Wed, 26 Sep 2012 02:16:44 +0000 (-0400) Subject: Fix: relayd relay_send_version: handle sscanf return code X-Git-Tag: v2.1.0-rc4~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7f51dcba1efdc03c85412a75ab71894a1b5af798;p=lttng-tools.git Fix: relayd relay_send_version: handle sscanf return code Signed-off-by: Christian Babeux Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index d01491e9c..dc6d2564a 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -1265,7 +1265,7 @@ static int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr, struct relay_command *cmd) { - int ret = htobe32(LTTNG_OK); + int ret; struct lttcomm_relayd_version reply; struct relay_session *session; @@ -1284,7 +1284,12 @@ int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr, } session->version_check_done = 1; - sscanf(VERSION, "%u.%u", &reply.major, &reply.minor); + ret = sscanf(VERSION, "%u.%u", &reply.major, &reply.minor); + if (ret < 2) { + ERR("Error in scanning version"); + ret = -1; + goto end; + } reply.major = htobe32(reply.major); reply.minor = htobe32(reply.minor); ret = cmd->sock->ops->sendmsg(cmd->sock, &reply,