From nobody Sun May 19 12:13:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1595524380; cv=none; d=zohomail.com; s=zohoarc; b=U91bDlSmOy4FJP1xHe+2NSG6vTCeCXXj+1W/OJsUxewaulzi8VSAg1Eg41jLOO2BZ7TIxhzXkWZ4lWcoNSXGOKiCRKwHnlBdojDeXHlamaSR+Wtk8wU1GMcAKWoTnsrA70eWXIxA1zm3oBT0loPFnMX1mYfZfOBiYnn1Wyjl9YI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595524380; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=tVqO/zUm8oBxk8F5vi2pyvX9bbKu7CPYJlBL+o34TT4=; b=X8lBBPJsoChiLI6whCAshFWXjMEtVuZJJCMUidHAUPDCdYykC5vXn+H7NWuSBYl1jul9XLzj3r03Q5bX9iyUN0V7FC/tldlU3o4L2tji9l5GfsCi9QO0NhvYxFABNNCYIgt/3besxNtvtPlhoY9JV7zkgk0V83bpuX2pygm4d00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15955243808433.592441969193942; Thu, 23 Jul 2020 10:13:00 -0700 (PDT) Received: from localhost ([::1]:44728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyemB-0001nB-2k for importer@patchew.org; Thu, 23 Jul 2020 13:12:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyelV-0001Jz-8Y for qemu-devel@nongnu.org; Thu, 23 Jul 2020 13:12:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49102 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jyelR-0007zn-Si for qemu-devel@nongnu.org; Thu, 23 Jul 2020 13:12:16 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-ixsQfMRoMxqwU9sya3K3bw-1; Thu, 23 Jul 2020 13:12:09 -0400 Received: by mail-wm1-f72.google.com with SMTP id z74so2570791wmc.4 for ; Thu, 23 Jul 2020 10:12:09 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id z16sm4398485wrr.35.2020.07.23.10.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 10:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595524332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tVqO/zUm8oBxk8F5vi2pyvX9bbKu7CPYJlBL+o34TT4=; b=S2Z/MJGjfYlXvINFDpo7uCzhzM2vyJ6KiumGlhTS+leKaiLJYxo1J6TVDN5FzVxsBuD7lc N7b4mZ2lVAYBlwQmYvQDaWcFi4ZUlNM/PTXByzHx2Jgm/yejw1BXdcxM6VQ+WwjtyMZp5H kiqVmHu37l3McvSzpW+xl3s3LD0D294= X-MC-Unique: ixsQfMRoMxqwU9sya3K3bw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tVqO/zUm8oBxk8F5vi2pyvX9bbKu7CPYJlBL+o34TT4=; b=nX4SXmN5sIFKmFzZKqpS/rbXzpJjihSXhkOwvZ2U2taxlvcTen3UZERFlBQA9nc2S3 mpyIF8nDyCF3kkLY+H7T0pQG1qT0GhZFUmX/cq9JaKzboDIY0UxTUn8o4ELk2sYmnGfJ xXBOgk9brgbwQXqAbJqJoLLaf7/2NxuZcMU88N5xIfdz9kE6VXQO2id9NBeI1mqKiR5+ 4d+PZ0/JfKdVDdj9ToOr0G2XhB8o+AgTBh3D6+ar3ATesQAqhWAFyPcdlhiIQtS5QMHj WIsJzB373//reAucpWxh7jYdnTZp9l6cIeJNPI7bJrAUvfH+aC3k4hQKxa4DQtoxgey+ ICng== X-Gm-Message-State: AOAM532cvQEopBbbuFIfpGF/DjwC7Y6gFUWRVPDahoLwkiHfyLRwjvHH S+nJOTkqedk2275YizhxsTrUz3QfbHALODARPoEJZtcBZCUh7LVm5FJTBIJDg7AgJv5tUFFuJFx 7boV6jLSc4YEsHTg= X-Received: by 2002:a1c:80d3:: with SMTP id b202mr5167149wmd.111.1595524328115; Thu, 23 Jul 2020 10:12:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4GMa3PL9mu/4Jaa4JkgUGW3hi5ooaurXr/KwDPByrFhERPezK3iWy9Mn69KJg4oTE7ptX1Q== X-Received: by 2002:a1c:80d3:: with SMTP id b202mr5167128wmd.111.1595524327887; Thu, 23 Jul 2020 10:12:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.1? v2] qapi/error: Check format string argument in error_*prepend() Date: Thu, 23 Jul 2020 19:12:05 +0200 Message-Id: <20200723171205.14949-1-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" 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=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/23 06:04:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Weil , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Michael Roth , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) error_propagate_prepend() "behaves like error_prepend()", and error_prepend() uses "formatting @fmt, ... like printf()". error_prepend() checks its format string argument, but error_propagate_prepend() does not. Fix by addint the format attribute to error_propagate_prepend() and error_vprepend(). This would have caught the bug fixed in the previous commit: CC hw/sd/milkymist-memcard.o hw/sd/milkymist-memcard.c: In function =E2=80=98milkymist_memcard_realize= =E2=80=99: hw/sd/milkymist-memcard.c:284:70: error: format =E2=80=98%s=E2=80=99 expe= cts a matching =E2=80=98char *=E2=80=99 argument [-Werror=3Dformat=3D] 284 | error_propagate_prepend(errp, err, "failed to init SD car= d: %s"); | = ~^ | = | | = char * Missed in commit 4b5766488f "error: Fix use of error_prepend() with &error_fatal, &error_abort". Inspired-by: Stefan Weil Suggested-by: Eric Blake Reviewed-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- Since v1: - Reword (Markus) - Add error_vprepend (Stefan) - Use local style to add the attribute *after* the declaration, which is invalid on definition where we get (depending on the toolchain): . error: attributes should be specified before the declarator in a functi= on definition . error: attributes are not allowed on a function-definition Supersedes: <20200723091309.18690-1-philmd@redhat.com> --- include/qapi/error.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/qapi/error.h b/include/qapi/error.h index 7932594dce..eaa05c4837 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -382,13 +382,15 @@ void error_propagate(Error **dst_errp, Error *local_e= rr); * Please use ERRP_GUARD() and error_prepend() instead when possible. */ void error_propagate_prepend(Error **dst_errp, Error *local_err, - const char *fmt, ...); + const char *fmt, ...) + GCC_FMT_ATTR(3, 4); =20 /* * Prepend some text to @errp's human-readable error message. * The text is made by formatting @fmt, @ap like vprintf(). */ -void error_vprepend(Error *const *errp, const char *fmt, va_list ap); +void error_vprepend(Error *const *errp, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); =20 /* * Prepend some text to @errp's human-readable error message. --=20 2.21.3