From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9F902959 for ; Tue, 16 Dec 2014 16:03:57 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 16 Dec 2014 07:03:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,587,1413270000"; d="scan'208";a="648505172" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 16 Dec 2014 07:03:54 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id sBGF3rhi008297; Tue, 16 Dec 2014 15:03:54 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id sBGF3r6b016837; Tue, 16 Dec 2014 15:03:53 GMT Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id sBGF3req016833; Tue, 16 Dec 2014 15:03:53 GMT From: Bruce Richardson To: dev@dpdk.org Date: Tue, 16 Dec 2014 15:03:51 +0000 Message-Id: <1418742233-16776-4-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1418742233-16776-1-git-send-email-bruce.richardson@intel.com> References: <1418742233-16776-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 3/5] examples: set correct limit for length of unix socket path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2014 15:03:58 -0000 The length of the path to a unix socket is not PATH_MAX but instead is UNIX_PATH_MAX which is generally just over 100 bytes in size. It's not actually defined in sys/un.h on linux - despite the man page referencing it, so calculate the size in the case where it's not defined. Signed-off-by: Bruce Richardson --- examples/vm_power_manager/channel_manager.c | 2 +- examples/vm_power_manager/channel_manager.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c index 7828be7..34a395d 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -597,7 +597,7 @@ get_info_vm(const char *vm_name, struct vm_info *info) ITERATIVE_BITMASK_CHECK_64(mask, i) { info->channels[channel_num].channel_num = i; memcpy(info->channels[channel_num].channel_path, - vm_info->channels[i]->channel_path, PATH_MAX); + vm_info->channels[i]->channel_path, UNIX_PATH_MAX); info->channels[channel_num].status = vm_info->channels[i]->status; info->channels[channel_num].fd = vm_info->channels[i]->fd; channel_num++; diff --git a/examples/vm_power_manager/channel_manager.h b/examples/vm_power_manager/channel_manager.h index 12c29c3..67e26ec 100644 --- a/examples/vm_power_manager/channel_manager.h +++ b/examples/vm_power_manager/channel_manager.h @@ -39,6 +39,7 @@ extern "C" { #endif #include +#include #include #include "channel_commands.h" @@ -54,6 +55,11 @@ extern "C" { /* File socket directory */ #define CHANNEL_MGR_SOCKET_PATH "/tmp/powermonitor/" +#ifndef UNIX_PATH_MAX +struct sockaddr_un _sockaddr_un; +#define UNIX_PATH_MAX sizeof(_sockaddr_un.sun_path) +#endif + /* Communication Channel Status */ enum channel_status { CHANNEL_MGR_CHANNEL_DISCONNECTED = 0, CHANNEL_MGR_CHANNEL_CONNECTED, @@ -68,7 +74,7 @@ enum vm_status { CHANNEL_MGR_VM_INACTIVE = 0, CHANNEL_MGR_VM_ACTIVE}; * the host. */ struct channel_info { - char channel_path[PATH_MAX]; /**< Path to host socket */ + char channel_path[UNIX_PATH_MAX]; /**< Path to host socket */ volatile uint32_t status; /**< Connection status(enum channel_status) */ int fd; /**< AF_UNIX socket fd */ unsigned channel_num; /**< CHANNEL_MGR_SOCKET_PATH/.channel_num */ -- 1.9.3