From nobody Mon Feb 9 01:51:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614696667; cv=none; d=zohomail.com; s=zohoarc; b=J0k5COk48vjE24T8zBK/wYv2CtvNk1FIkKWekZPHwM9mv945T6XDdeHMlUbPOZ07CjNn1TMevVmB7teZWH83aRSLWIeg9e90odagLcskb8tHVxbx8GwaYfzfpPP4/28lt5/pHydt/kOcZslSqQ14rcpZHv7PG26Qca2+7rBqgHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614696667; h=Content-Type:Content-Transfer-Encoding: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=4BHM7Ol3SQKWuqEXvAcYVCwVctU52DO+sxyH9jTlf/M=; b=l68sAf3hGUHMc4HJwb4I2rF/iVJnkddCFaHyVw//wxZoXCAVyxO3VXHQYOfDQrQT3Ldwd4+lvuApEIH62FEcTHl2gKdlAdgxp331SzeHXLBKUo1XaHeSHW0eoYNwk1jVYOo2JMwMNdeEMKkSkPcIWl8sOLx2ZgLUxnlQe4UlYXA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 161469666780665.85202459940683; Tue, 2 Mar 2021 06:51:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-fCWizUGOOyWdnWx-EU_mMg-1; Tue, 02 Mar 2021 09:50:18 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D763100CCC8; Tue, 2 Mar 2021 14:50:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B66060C13; Tue, 2 Mar 2021 14:50:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B9D4818089D2; Tue, 2 Mar 2021 14:50:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 122EnqwW014543 for ; Tue, 2 Mar 2021 09:49:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A1295D722; Tue, 2 Mar 2021 14:49:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA60E5D766 for ; Tue, 2 Mar 2021 14:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614696666; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4BHM7Ol3SQKWuqEXvAcYVCwVctU52DO+sxyH9jTlf/M=; b=TL8xG5TtYyi6v66lzkDPcoX5sTjeM3dLNLYq/UYFtYLi2W1djdqOCYY0OHraXlHqCQUFu8 Luco+qGtU2OxOgj5VBv93N8lehqHAZdlHvLo3dywm/XYLgIjJeMWE5W54gJhlECfsszaO7 6ptbamtGrCJpD9gphIXFIXbyMOfLjTo= X-MC-Unique: fCWizUGOOyWdnWx-EU_mMg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/16] xenParseXLUSB: Rewrite to avoid virStrncpy Date: Tue, 2 Mar 2021 15:49:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libxl/xen_xl.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 1bce31a549..29c145851e 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -960,14 +960,10 @@ xenParseXLUSB(virConfPtr conf, virDomainDefPtr def) if (list && list->type =3D=3D VIR_CONF_LIST) { list =3D list->list; while (list) { - char bus[3]; - char device[3]; char *key; int busNum; int devNum; - bus[0] =3D device[0] =3D '\0'; - if ((list->type !=3D VIR_CONF_STRING) || (list->str =3D=3D NUL= L)) goto skipusb; /* usbdev=3D['hostbus=3D1,hostaddr=3D3'] */ @@ -982,20 +978,16 @@ xenParseXLUSB(virConfPtr conf, virDomainDefPtr def) if (STRPREFIX(key, "hostbus=3D")) { int len =3D nextkey ? (nextkey - data) : strlen(data); - if (virStrncpy(bus, data, len, sizeof(bus)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("bus %s too big for destination"), - data); + g_autofree char *tmp =3D g_strndup(data, len); + + if (virStrToLong_i(tmp, NULL, 16, &busNum) < 0) goto skipusb; - } } else if (STRPREFIX(key, "hostaddr=3D")) { int len =3D nextkey ? (nextkey - data) : strlen(data); - if (virStrncpy(device, data, len, sizeof(device)) < 0)= { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("device %s too big for destinatio= n"), - data); + g_autofree char *tmp =3D g_strndup(data, len); + + if (virStrToLong_i(tmp, NULL, 16, &devNum) < 0) goto skipusb; - } } while (nextkey && (nextkey[0] =3D=3D ',' || @@ -1005,10 +997,6 @@ xenParseXLUSB(virConfPtr conf, virDomainDefPtr def) key =3D nextkey; } - if (virStrToLong_i(bus, NULL, 16, &busNum) < 0) - goto skipusb; - if (virStrToLong_i(device, NULL, 16, &devNum) < 0) - goto skipusb; if (!(hostdev =3D virDomainHostdevDefNew())) return -1; --=20 2.29.2