From nobody Tue Apr 15 06:09:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659447937; cv=none; d=zohomail.com; s=zohoarc; b=Kp6hI97FUitU7CWYF8F9+XC+lSyva/lGgs00uZIXClo5cdXaoiZB+qH6qDJFyUigYRzG/Jzbkm5Jd/jSDw0YGX+hml8pOv5pFxs8cxkAsT8+pmb1q5msaHoAhQQ0M04FO41yYPOejjJLxvbg774lCSFkBhA8ikZV8OJ+rr+CFmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659447937; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AFPrwYhk7XoJbqRc6nAUA+SaC++OjEGxIi419e5RF74=; b=Z/rWwIKeaBjlCZzgoGfEyjDZoro1PtfgAjnOTXCQr2J1l6wj/MELhKVFbcesFypuR2T2jcwLQIp8rK2JBKUyW0NMgVQi6fGwIqfovay2hoFhQED+3J5K3VM28pPHtf6QFC/pzQaDj23IdnUOaIxMcqEJMJ7Z/63PogHmMSC4+Tk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659447937637680.5199552188866; Tue, 2 Aug 2022 06:45:37 -0700 (PDT) Received: from localhost ([::1]:60116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIsDI-00071z-9J for importer@patchew.org; Tue, 02 Aug 2022 09:45:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIs66-0003a5-T1 for qemu-devel@nongnu.org; Tue, 02 Aug 2022 09:38:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIs63-0002aH-3V for qemu-devel@nongnu.org; Tue, 02 Aug 2022 09:38:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-r1viZMa-MguoK87l5fXAPA-1; Tue, 02 Aug 2022 09:38:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07F2E101E986; Tue, 2 Aug 2022 13:38:05 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A622166B26; Tue, 2 Aug 2022 13:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659447486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AFPrwYhk7XoJbqRc6nAUA+SaC++OjEGxIi419e5RF74=; b=NKKce3d6f3BY2wYfeHVQeBL4639bt5wSTowk8o7yn0sShQ19uONpLSbDn4JQKB54dZWmIW IJmZOJ5EEZcdR7VC+sLVONP+mXTMjRyueLYugffDx5meP+0mmh0BU6yHev+P0jYO94Ashx MWQqf2Eb/apxZd3L5+T4M8YF/hWHjLc= X-MC-Unique: r1viZMa-MguoK87l5fXAPA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 3/7] libvduse: Replace strcpy() with strncpy() Date: Tue, 2 Aug 2022 15:37:53 +0200 Message-Id: <20220802133757.138016-4-kwolf@redhat.com> In-Reply-To: <20220802133757.138016-1-kwolf@redhat.com> References: <20220802133757.138016-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659447939486100001 Content-Type: text/plain; charset="utf-8" From: Xie Yongji Coverity reported a string overflow issue since we copied "name" to "dev_config->name" without checking the length. This should be a false positive since we already checked the length of "name" in vduse_name_is_invalid(). But anyway, let's replace strcpy() with strncpy() (as a general library, we'd like to minimize dependencies on other libraries, so we didn't use g_strlcpy() here) to fix the coverity complaint. Fixes: Coverity CID 1490224 Signed-off-by: Xie Yongji Reviewed-by: Markus Armbruster Message-Id: <20220706095624.328-3-xieyongji@bytedance.com> Signed-off-by: Kevin Wolf --- subprojects/libvduse/libvduse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvdus= e.c index 6374933881..1e36227388 100644 --- a/subprojects/libvduse/libvduse.c +++ b/subprojects/libvduse/libvduse.c @@ -1309,7 +1309,8 @@ VduseDev *vduse_dev_create(const char *name, uint32_t= device_id, goto err_dev; } =20 - strcpy(dev_config->name, name); + strncpy(dev_config->name, name, VDUSE_NAME_MAX); + dev_config->name[VDUSE_NAME_MAX - 1] =3D '\0'; dev_config->device_id =3D device_id; dev_config->vendor_id =3D vendor_id; dev_config->features =3D features; --=20 2.35.3