From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 460F1D8048F for ; Fri, 10 Jan 2025 08:19:32 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=W/qz+6m2P4f+DTZgLgZfLbTV16XUQk2rgxBrFEfChLI=; c=relaxed/simple; d=groups.io; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:User-Agent:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Disposition; s=20240830; t=1736497171; v=1; x=1736756370; b=XUd5UZg32wZzasE1Wt7ibcSOq/6Z11/zEhA1dxDJQrTmQJ6if4MOG8i27LlS/5p3PgWdvBmo woGIcvG5mGSg/z1d42PBanmKgzwqMWDVZPK+u5XbN2Dj8a5Tabo7X7HYW/yocDRoyMK3bUQuKzx a8KBUi/HkbUdu/CTrnv6+V0fuFrbnF349QT9gmCGgdMFv4ahhzaJ2yZsIkyxoN4bMn7ENatlJNV S5pczBle7FxRvsSsPBTwQ4yzmiAsEoeZpTq0lmKbYKF0fC25ED9b73QLRnocaJ4G2xYdY/ZWMLC ILIs8hYj7D+G+XqN7BrblFtbAWTSNn1EAGMK2IFiMf+jg== X-Received: by 127.0.0.2 with SMTP id dZerYY7687511xuSDpmKlfWD; Fri, 10 Jan 2025 00:19:30 -0800 X-Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by mx.groups.io with SMTP id smtpd.web10.14171.1736497169708759237 for ; Fri, 10 Jan 2025 00:19:30 -0800 X-Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-aaf60d85238so344350266b.0 for ; Fri, 10 Jan 2025 00:19:29 -0800 (PST) X-Gm-Message-State: ImzjuNpir6Id4FAAUlwejXVKx7686176AA= X-Gm-Gg: ASbGncv8YrySsvp5gYx7ch/SRty+C3I6tXSCn3zN+A5NQ62Hpw6PaI2EKKh4LRkseZJ mB+NBEYK3HPgKpXr0XQd0F0qd27rmYuokaCuPJElervI4acwSTi++1+iMz8dOLlRXcrOWKT3sj6 ST8Nj1LVCYgaLM8tdf8/O+8Ho2MhfmnvPvuWtXKTsR3tZKgNEg81JNAqQQS9jmKMJmgbbD3sQKC VA7GC2QkaW8u/Ap053XwAd56km5apmBdam7M8YLlsjNxsFkqu4F0LtA6cAweMfTjVzKl73PI2a3 jva/u1yr2909czIfPMjH8R8b53P7 X-Google-Smtp-Source: AGHT+IFF3mZPZ9RBUos52tJG5IWn+LeOV2DsEhHmM9s6qOvp/LyhNWcCFEXctedCERfITEulSTFlHQ== X-Received: by 2002:a17:907:2da3:b0:aac:622:8f6 with SMTP id a640c23a62f3a-ab2ab6c5066mr853015766b.17.1736497167681; Fri, 10 Jan 2025 00:19:27 -0800 (PST) X-Received: from localhost.localdomain (1-164-75-125.dynamic-ip.hinet.net. [1.164.75.125]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d4068179asm1095495b3a.130.2025.01.10.00.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 00:19:27 -0800 (PST) Date: Fri, 10 Jan 2025 16:19:23 +0800 From: "Richard Lyu via groups.io" To: devel@edk2.groups.io Cc: Richard Lyu Subject: [edk2-devel] [PATCH] MdePkg/DebugLib: Add null pointer check to CR macro Message-ID: <20250110081608.26400-3-richard.lyu@suse.com> MIME-Version: 1.0 User-Agent: Mutt/2.2.13 (2024-03-09) Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 10 Jan 2025 00:19:30 -0800 Resent-From: richard.lyu@suse.com Reply-To: devel@edk2.groups.io,richard.lyu@suse.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=XUd5UZg3; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io - Added a null pointer check in the CR macro. - If Record is NULL, an assertion is triggered. - This change improves the CR by preventing dereferencing of null pointers. REF: https://github.com/tianocore/edk2/issues/10510 Signed-off-by: Richard Lyu --- MdePkg/Include/Library/DebugLib.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index b48e08a7e4..084714d4d3 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -657,11 +657,12 @@ UnitTestDebugAssert ( **/ #if !defined (MDEPKG_NDEBUG) #define CR(Record, TYPE, Field, TestSignature) \ + ((Record == NULL) ? (TYPE *) (_ASSERT (CR has Null Pointer), Record) : \ (DebugAssertEnabled () && (BASE_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \ (TYPE *) (_ASSERT (CR has Bad Signature), Record) : \ (BASE_CR (Record, TYPE, Field)->Signature != TestSignature) ? \ NULL : \ - BASE_CR (Record, TYPE, Field) + BASE_CR (Record, TYPE, Field)) #else #define CR(Record, TYPE, Field, TestSignature) \ (BASE_CR (Record, TYPE, Field)->Signature != TestSignature) ? \ -- 2.43.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120979): https://edk2.groups.io/g/devel/message/120979 Mute This Topic: https://groups.io/mt/110531848/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-