From patchwork Fri Jul 3 09:34:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 50612 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E9E6214B3 for ; Fri, 3 Jul 2015 09:35:43 +0000 (UTC) Received: by wiar9 with SMTP id r9sf30920757wia.1 for ; Fri, 03 Jul 2015 02:35:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=fAYg8K5jmVovk+19eHaFeyIIMZigkqJJcJi8mfpvmzo=; b=JhCw8lx2IiDgt2QoS+sKm1YSbCA2CLRKc2P49T2FUGCTRMKqw+BX0B1ifhW6DjnOoi 6+MqsXh/Btjr3aLJugLCNgAP68KtWxKCtZXfefN81qC+k/ltWVNUyw7xd88i2Caso05j FQeO2dmcm9nia1gsPNewvDdsLWPz7opzW4zmEjZC4TVaaS7uYjb/RLRZhzL6mykRP7HR FtR/MpKxWEsM1KIC1P0+TCl54tjoHH0NfoVc92IxtRuomShkIfpKt5hUjyPhvxBGPNm0 tUo7naTfa8EbTOlBD0qPz95s1+6WzEF+Q4GIM8ZLu3j9ct9ExhKFcB/eqPq32ZUFrXFu U+/A== X-Gm-Message-State: ALoCoQmEtM63Lh0a5u55qDMdIe/YlF6NsuHCbJamxGmVVs+smVxN9YfwiEWscy083uq+CNLtLyEb X-Received: by 10.112.14.101 with SMTP id o5mr22128021lbc.3.1435916142797; Fri, 03 Jul 2015 02:35:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.232 with SMTP id r8ls427070lal.55.gmail; Fri, 03 Jul 2015 02:35:42 -0700 (PDT) X-Received: by 10.152.88.6 with SMTP id bc6mr20910668lab.23.1435916142650; Fri, 03 Jul 2015 02:35:42 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id th3si6738405lbb.146.2015.07.03.02.35.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jul 2015 02:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lagc2 with SMTP id c2so78594826lag.3 for ; Fri, 03 Jul 2015 02:35:42 -0700 (PDT) X-Received: by 10.112.234.200 with SMTP id ug8mr34666628lbc.117.1435916142518; Fri, 03 Jul 2015 02:35:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1043140lbb; Fri, 3 Jul 2015 02:35:41 -0700 (PDT) X-Received: by 10.50.61.241 with SMTP id t17mr21063856igr.34.1435916139188; Fri, 03 Jul 2015 02:35:39 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id l1si4844602igx.50.2015.07.03.02.35.38 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 03 Jul 2015 02:35:39 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZAxNZ-0001Fe-Ry; Fri, 03 Jul 2015 09:35:29 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZAxNX-0001FS-UM for edk2-devel@lists.sourceforge.net; Fri, 03 Jul 2015 09:35:27 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.192.175 as permitted sender) client-ip=209.85.192.175; envelope-from=heyi.guo@linaro.org; helo=mail-pd0-f175.google.com; Received: from mail-pd0-f175.google.com ([209.85.192.175]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ZAxNX-00040Q-6O for edk2-devel@lists.sourceforge.net; Fri, 03 Jul 2015 09:35:27 +0000 Received: by pdbep18 with SMTP id ep18so61087509pdb.1 for ; Fri, 03 Jul 2015 02:35:21 -0700 (PDT) X-Received: by 10.66.65.228 with SMTP id a4mr20268274pat.65.1435916121527; Fri, 03 Jul 2015 02:35:21 -0700 (PDT) Received: from localhost.localdomain ([180.150.148.224]) by mx.google.com with ESMTPSA id sl9sm8437289pac.41.2015.07.03.02.35.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jul 2015 02:35:20 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.sourceforge.net Date: Fri, 3 Jul 2015 17:34:40 +0800 Message-Id: <1435916081-27645-2-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435916081-27645-1-git-send-email-heyi.guo@linaro.org> References: <1435916081-27645-1-git-send-email-heyi.guo@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1ZAxNX-00040Q-6O Subject: [edk2] [PATCH 1/2] MdePkg: Fix bug in CatVSPrint introduced by r17742 X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: heyi.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 SVN r17742 uses AllocateCopyPool to replace AllocateZeroPool, however String can be NULL and this will trigger assert in AllocateCopyPool. Error Can be replayed when we use "cd " command under Shell. Just use a more conservative way to replace unsafe StrCpy. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo --- MdePkg/Library/UefiLib/UefiLibPrint.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c b/MdePkg/Library/UefiLib/UefiLibPrint.c index cc41eb0..604c25b 100644 --- a/MdePkg/Library/UefiLib/UefiLibPrint.c +++ b/MdePkg/Library/UefiLib/UefiLibPrint.c @@ -754,12 +754,16 @@ CatVSPrint ( SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16)); } - BufferToReturn = AllocateCopyPool(SizeRequired, String); + BufferToReturn = AllocateZeroPool(SizeRequired); if (BufferToReturn == NULL) { return NULL; } + if (String != NULL) { + StrCpyS(BufferToReturn, SizeRequired, String); + } + UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker); ASSERT(StrSize(BufferToReturn)==SizeRequired);