From patchwork Thu Nov 3 17:31:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 80705 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp750706qge; Thu, 3 Nov 2016 10:31:35 -0700 (PDT) X-Received: by 10.98.198.85 with SMTP id m82mr18610930pfg.69.1478194295146; Thu, 03 Nov 2016 10:31:35 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id y6si9016090pay.142.2016.11.03.10.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Nov 2016 10:31:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 84FFA81D27; Thu, 3 Nov 2016 10:31:32 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CAC2881CF0 for ; Thu, 3 Nov 2016 10:31:30 -0700 (PDT) Received: by mail-wm0-x231.google.com with SMTP id a197so1186647wmd.0 for ; Thu, 03 Nov 2016 10:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9NAkTFkDyFzhSXUt71kS/E4o6oQ2ioAi1yO/cQb62w4=; b=TUUTxtKSnlmGBLxvWI2airuMp8LRZz3iP/2c6SMKT+FcOP2XaFSmh1f6uxB7Nl8M45 rZ8BBTPpuw4PMdHHxxMEWmOASc2kGEj0NSQGK43L8vu6ITkp64Ax7HCjdWcMju9KDCZy 1pOUfoUQtmLaUfO47IvjblkTjbGbbEf8nyPuc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9NAkTFkDyFzhSXUt71kS/E4o6oQ2ioAi1yO/cQb62w4=; b=TBKGSBC2sbOFyrLS9+L9Z2/MJgUNJv/AiLGEtKmBqb1HCgc29Shgup5w6w+B6bxZJw 2oxtDiv0lW1n0OMT46w2bV6/1wPNzVWfNJxrQxuM0q/Oly5HynaJMK4SYwSW/NSoEpLo 1w3yVDKZrPkibwG/ZEHc3C7F6Rrq3lFD8nAnl1TpOVSk+TYi/Ht7v8wrM2sTlXdimvxl DiQ7YT6uI5EUERqPlVgxE4Al3MhwhL0NDYSGtFsy80rlgmAtV5m2F4RjGUoBO8dtJlEx p21xBKeU+yBHmffGCIg5i6v+QWlJN5mYElAbVxp74Og4qRogt1Mf7sw4rkPaUPwhSjmt JIkQ== X-Gm-Message-State: ABUngvecf0Ci3QkcK52C4sniKolZISfMBNGGUK2Z8oTZzO0TSJXRxwQuNFzj1LHDv1ljttoY X-Received: by 10.28.103.134 with SMTP id b128mr9899270wmc.54.1478194290342; Thu, 03 Nov 2016 10:31:30 -0700 (PDT) Received: from localhost.localdomain ([105.151.153.127]) by smtp.gmail.com with ESMTPSA id a1sm9754939wjl.28.2016.11.03.10.31.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Nov 2016 10:31:29 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, michael.d.kinney@intel.com, liming.gao@intel.com Date: Thu, 3 Nov 2016 17:31:14 +0000 Message-Id: <1478194274-16524-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [edk2] [PATCH] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem () X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Unlike other string functions in this library, ZeroMem () does not return early when the length of the input buffer is 0. So add the same to ZeroMem () as well. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c index 2a0a038fd6c5..fbc2f5742c8c 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c @@ -46,6 +46,10 @@ ZeroMem ( IN UINTN Length ) { + if (Length == 0) { + return Buffer; + } + ASSERT (!(Buffer == NULL && Length > 0)); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); return InternalMemZeroMem (Buffer, Length);