From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXOZ1-0005xN-1p for qemu-devel@nongnu.org; Mon, 16 Mar 2015 02:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXOYu-0003f5-8M for qemu-devel@nongnu.org; Mon, 16 Mar 2015 02:31:46 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:34549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXOYt-0003YR-Kd for qemu-devel@nongnu.org; Mon, 16 Mar 2015 02:31:40 -0400 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Mar 2015 12:01:34 +0530 From: "Aneesh Kumar K.V" In-Reply-To: <1426298416-884-1-git-send-email-zhaoshenglong@huawei.com> References: <1426298416-884-1-git-send-email-zhaoshenglong@huawei.com> Date: Mon, 16 Mar 2015 12:01:24 +0530 Message-ID: <87ioe1mp1f.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2] fsdev/virtfs-proxy-helper: Fix possible overflow List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Shannon Zhao , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, qemu-trivial@nongnu.org, mjt@tls.msk.ru, peter.huangpeng@huawei.com, shannon.zhao@linaro.org, pbonzini@redhat.com Shannon Zhao writes: > It's detected by coverity. As max of sockaddr_un.sun_path is > sizeof(helper.sun_path), should check the length of source > and use strncpy instead of strcpy. updated such that, The socket name specified should fit in the sockadd_un.sun_path. If not abort. with that applied. > > Signed-off-by: Shannon Zhao > Signed-off-by: Shannon Zhao > --- > v1->v2: Still use strcpy [Paolo] > --- > fsdev/virtfs-proxy-helper.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c > index bf2e5f3..13fe032 100644 > --- a/fsdev/virtfs-proxy-helper.c > +++ b/fsdev/virtfs-proxy-helper.c > @@ -738,6 +738,7 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid) > return -1; > } > > + g_assert(strlen(path) < sizeof(proxy.sun_path)); > sock = socket(AF_UNIX, SOCK_STREAM, 0); > if (sock < 0) { > do_perror("socket"); > -- > 1.8.3.1