From patchwork Fri Dec 17 20:10:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1570345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JG0ZN6jp2z9sVq for ; Sat, 18 Dec 2021 07:14:36 +1100 (AEDT) Received: from localhost ([::1]:59446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1myJcg-0004yp-On for incoming@patchwork.ozlabs.org; Fri, 17 Dec 2021 15:14:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myJYm-0005zx-CV; Fri, 17 Dec 2021 15:10:32 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:33149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myJYk-0001Ke-PB; Fri, 17 Dec 2021 15:10:32 -0500 Received: from quad ([82.142.30.186]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N2lzA-1mUMXO1t4W-0138e5; Fri, 17 Dec 2021 21:10:26 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 9/9] checkpatch: Do not allow deprecated g_memdup() Date: Fri, 17 Dec 2021 21:10:19 +0100 Message-Id: <20211217201019.1652798-10-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217201019.1652798-1-laurent@vivier.eu> References: <20211217201019.1652798-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:n/0qUk+ExpCi1UzF9vwS45WsPPf2mwPWWO2GJ9rfDGfVjQqWMPv t6QsnZSNduTTgQzTm0Kxe6rOkaGJbxgjZwmu3D/+7jlTUmUNuf16DNr33VSY81/ldFEO0Hh HnGdOcK4YqQsE+lIEScWenWNdi1uIPuXGsle4NWxAaurJz490B1Ys32sbA3AL1sMLBVPDpN 7lT1tKlVLPF8n0mlEgUOg== X-UI-Out-Filterresults: notjunk:1;V03:K0:swnoLcIIHrc=:B+upXRvFACYoJr0Z3Ffkxc be4ez8vZNZ09q9IaDUZsx1UQRVw48yBYIm2ip4FCBnDHtNwfYMSkalMuMZyFsR0jTGZhrPt9n x4F8VYWrKSK0g8aXtGvxKsLSFBT1To7fHbMLtFLWfaBd8Ugzj49jhx84+3GCtNzeYWNeVKQss xNThTOOJxQK++I+sBE388/ptpbW2v6x8k6porhjlA3HhxcHtLTuo3CBLA+m8mxpipbkhY+Iqf NPf/pGK6KWZGkfvFQNumI2Yly4+3Uh95XrVexFyJneH1G1I5hgLLcgrpZis2sJM1XfFLIdT08 GUv4yf4NUUoRA0oC2B1AVCMAvTfMEm1bvL01futC7ETLkeY9TxLxpBvTKdEms3AFFMNedXVxh X6wh5Z1pVhCDfSNlie03SUIDV6kb+GL7BStvx7g27TDWufNZ6K/rn0zJnjmssU5rH2ghrOQ/K kBLykbR/u4kBwkN45XawjTdWFOkXOKGBKQ0FdAZw7/NJbP/C2xJb6IpX2FRNGEpuavPw1kn1h vTuZycn9+knKjGRP7l6RmnMBQxMH/984zQKn97/XEJZJyGK0fw46Cb7idESXX0//jLcvNODlX D7zlKcMdXxttejfLJYufvS/CroNm+4ciaoAx9LWaAVQBwiDGBDJvpE5usJJCWysKHHsiZGz1d u3PwzsGrkC5D2rEUSOdO8+XbG+qE33MT5wOlSVivjSRGaRLac8qM20hxoPUr5LcZ6rbw= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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: , Cc: qemu-trivial@nongnu.org, Eric Blake , =?utf-8?q?Phili?= =?utf-8?q?ppe_Mathieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé g_memdup() is insecure and as been deprecated in GLib 2.68. QEMU provides the safely equivalent g_memdup2() wrapper. Do not allow more g_memdup() calls in the repository, provide a hint to use g_memdup2(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Message-Id: <20210903174510.751630-29-philmd@redhat.com> Signed-off-by: Laurent Vivier --- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index cb8eff233e06..5caa739db486 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2850,6 +2850,11 @@ sub process { WARN("consider using g_path_get_$1() in preference to g_strdup($1())\n" . $herecurr); } +# enforce g_memdup2() over g_memdup() + if ($line =~ /\bg_memdup\s*\(/) { + ERROR("use g_memdup2() instead of unsafe g_memdup()\n" . $herecurr); + } + # recommend qemu_strto* over strto* for numeric conversions if ($line =~ /\b(strto[^kd].*?)\s*\(/) { ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);