From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: Ard Biesheuvel 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: [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: , X-List-Received-Date: Thu, 03 Nov 2016 17:31:31 -0000 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(+) 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); -- 2.7.4