From patchwork Sat Mar 14 01:59:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 450137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5DB961400B7 for ; Sat, 14 Mar 2015 13:03:17 +1100 (AEDT) Received: from localhost ([::1]:39283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWbQ3-0007eK-KU for incoming@patchwork.ozlabs.org; Fri, 13 Mar 2015 22:03:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWbPm-0007JD-BZ for qemu-devel@nongnu.org; Fri, 13 Mar 2015 22:02:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWbPj-0002Qz-6a for qemu-devel@nongnu.org; Fri, 13 Mar 2015 22:02:58 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:15918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWbPi-0002QQ-Gu; Fri, 13 Mar 2015 22:02:55 -0400 Received: from 172.24.2.119 (EHLO szxeml428-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CKT74269; Sat, 14 Mar 2015 09:59:31 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml428-hub.china.huawei.com (10.82.67.183) with Microsoft SMTP Server id 14.3.158.1; Sat, 14 Mar 2015 09:59:24 +0800 From: Shannon Zhao To: Date: Sat, 14 Mar 2015 09:59:13 +0800 Message-ID: <1426298353-8628-1-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, qemu-trivial@nongnu.org, mjt@tls.msk.ru, peter.huangpeng@huawei.com, aneesh.kumar@linux.vnet.ibm.com, pbonzini@redhat.com, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v2] hw/9pfs/virtio-9p-proxy: Fix possible overflow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- v1->v2: Still use strcpy [Paolo] --- hw/9pfs/virtio-9p-proxy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c index 59c7445..5ebfaf6 100644 --- a/hw/9pfs/virtio-9p-proxy.c +++ b/hw/9pfs/virtio-9p-proxy.c @@ -1102,6 +1102,7 @@ static int connect_namedsocket(const char *path) int sockfd, size; struct sockaddr_un helper; + g_assert(strlen(path) < sizeof(helper.sun_path)); sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) { fprintf(stderr, "failed to create socket: %s\n", strerror(errno));