From 3affbebbcdea73856053d302486ddcc3759c3029 Mon Sep 17 00:00:00 2001 From: Nikita Kalyazin Date: Tue, 20 Aug 2013 09:42:34 +0400 Subject: [PATCH] [FIX] wrong app arguments strip Fix for 40fa9c37f665eb60442bf53ae5730f17ef6cda98. If there are no arguments, invalid app path is returned. --- daemon/da_protocol.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/daemon/da_protocol.c b/daemon/da_protocol.c index a670995..f6f88ef 100644 --- a/daemon/da_protocol.c +++ b/daemon/da_protocol.c @@ -259,10 +259,14 @@ static int parse_int64(struct msg_buf_t *msg, uint64_t *val) static void strip_args(const char *cmd, char *path) { char *bin_end = strchr(cmd, ' '); - size_t binname_len = bin_end - cmd; - memcpy(path, cmd, binname_len); - path[binname_len] = '\0'; + if (!bin_end) { + strcpy(path, cmd); + } else { + size_t binname_len = bin_end - cmd; + memcpy(path, cmd, binname_len); + path[binname_len] = '\0'; + } } static int parse_app_info(struct msg_buf_t *msg, -- 2.7.4