From nobody Sun May 19 05:50:58 2024 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1653989495; cv=none; d=zohomail.com; s=zohoarc; b=WBuab/H0cqqjg5s0xIWXf7+ipq8uAukO1ZN+MTGpXxRQ5UApIMEVFU3GUvqlVaNoakeRp8hxHjzPpypqwzCIRCcq4erhZY8F5Hc5Mj6ogk6u0BbB8dVye7ZvgpgpRWvXqqbJoMnWn2xEi1JNGMYh1UBeDiTTHcFXyi3UkRT+lgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653989495; 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=BMyW7YvYfdXoUUQ6CLwB02Lx4UJvEtP1magnfsvicy0=; b=gVFmi6J5KuKDVrcdeX2AAP4PAmTXX5tc497qEskLdnsw/A1dJvLWnFZl6m49BxosOfXdKC3iCn2nqKaqepTLEK5d479qC9vIrkTr3zRPHKjdacV5ackh0MOGNg9nnrQQg5qezMXddml1iYZoGQjg5ZmsDl3558j7xVgsWTH44yo= 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 165398949597043.95434239795782; Tue, 31 May 2022 02:31:35 -0700 (PDT) Received: from localhost ([::1]:47908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvyDs-0001qg-Nz for importer@patchew.org; Tue, 31 May 2022 05:31:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvy8e-0008CN-P7 for qemu-devel@nongnu.org; Tue, 31 May 2022 05:26:08 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:44732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nvy8X-0008AE-MU for qemu-devel@nongnu.org; Tue, 31 May 2022 05:26:08 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 48DBF21BED; Tue, 31 May 2022 09:25:58 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 16089132F9; Tue, 31 May 2022 09:25:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aN7OAybflWIBEQAAMHmgww (envelope-from ); Tue, 31 May 2022 09:25:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1653989158; h=from:from:reply-to: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=BMyW7YvYfdXoUUQ6CLwB02Lx4UJvEtP1magnfsvicy0=; b=wGso+cZrc/xaI3ePVVWmrAV/QeUA3mDZn0gTbQdkUoSBSBI/xxSZZUotQARZwIX+Pp2lIf ytpC4kwwVGycGoMLpQ0bXtM9CHSw0x8QTrK5/HTmFdBw+CSCh+SjR5kEfVpsdkggDNNzx9 8Xj1qowm7AIL+/2ypsZGMQURGTqrIsc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1653989158; h=from:from:reply-to: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=BMyW7YvYfdXoUUQ6CLwB02Lx4UJvEtP1magnfsvicy0=; b=Ja8R4v7gobTEmEiA2F++FWzotT6dgLJGf357VtX6fBixWAPB/j02hKLcDy/t0radCtxfBb I5oCPMZElvnsdMBg== From: Claudio Fontana To: "Michael S. Tsirkin" Cc: Marcel Apfelbaum , qemu-devel@nongnu.org, Dario Faggioli , Claudio Fontana Subject: [PATCH] pci: fix overflow in printf string formatting Date: Tue, 31 May 2022 11:25:40 +0200 Message-Id: <20220531092540.10151-2-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220531092540.10151-1-cfontana@suse.de> References: <20220531092540.10151-1-cfontana@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=195.135.220.28; envelope-from=cfontana@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1653989497390100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Claudio Fontana --- hw/pci/pci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index a9b37f8000..6e7015329c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2640,15 +2640,15 @@ static char *pci_dev_fw_name(DeviceState *dev, char= *buf, int len) static char *pcibus_get_fw_dev_path(DeviceState *dev) { PCIDevice *d =3D (PCIDevice *)dev; - char path[50], name[33]; - int off; - - off =3D snprintf(path, sizeof(path), "%s@%x", - pci_dev_fw_name(dev, name, sizeof name), - PCI_SLOT(d->devfn)); - if (PCI_FUNC(d->devfn)) - snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn)= ); - return g_strdup(path); + char name[33]; + int has_func =3D !!PCI_FUNC(d->devfn); + + return g_strdup_printf("%s@%x%s%.*x", + pci_dev_fw_name(dev, name, sizeof(name)), + PCI_SLOT(d->devfn), + has_func ? "," : "", + has_func, + PCI_FUNC(d->devfn)); } =20 static char *pcibus_get_dev_path(DeviceState *dev) --=20 2.26.2