From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by mx.groups.io with SMTP id smtpd.web09.2230.1582182248441157537 for ; Wed, 19 Feb 2020 23:04:08 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fFAMeSLc; spf=pass (domain: gmail.com, ip: 209.85.215.194, mailfrom: newexplorerj@gmail.com) Received: by mail-pg1-f194.google.com with SMTP id y30so1434587pga.13 for ; Wed, 19 Feb 2020 23:04:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Bh0q3QbM8IrsTYfqSZkOIwrJe+pTRs6VHI5AXTsumG0=; b=fFAMeSLcshlKQRtY/78TqjiZ7y53CdL+Kz/xQmAYJcVgKSQhiF2otvy1YK/NfdRlNi 7E7JMsEZQtfEjjNh5OffcZp134vFRLvbGhIJu70/gGkyVdq+loex6pDgg/Ee247mXXCn Gt/6MfzENzOopaSKtOH/Tt/c3CGjY/Ol832hB26iNFqhmFrBMj2CUNL9YrCudMTAv7SS UeVJZLrMy0iIKrW+Ie2ASYxT3yVM4CbO7juARvNqqGPrpMo8dbx4D4qRY152Cvg3AaSn ZY/8Od6jhFgaKaFTOJg4Y0UXWpdbHJUQEH+yOhc5B/3IqmNt54iZPG9gMf4yBuqEuMhg 7mVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Bh0q3QbM8IrsTYfqSZkOIwrJe+pTRs6VHI5AXTsumG0=; b=Fsmlx18Fa/dKwA+pPfeIWsZz+j3pSMW+7qrZ1q1dsZxJvsXuIg5ZYopEu70uUpPqgs KRusr0vNmwf7VxJK+7pmK/BlP0od3oDuyWnyHso1kaNkPc0hmvI40pemcGDN96k1BRXA FQZssIBfxE7BDMURtpqduRalC6LLq81wdfD4K9RI1+DdvI3r1KeyvG+K8GyN+UY+BW/q 3tAOgsYK4b6kyCK9/SgP1JWVEDVwi1QbVWGk2UhzHxPT6PHrFa4cZAQJUlfdlzAf2nXS 1eSG//a0UvXy2sgAwgUke2Y8HB5f4gP83jxfG8N/iiLpT8MP8DmP7dhmDIRCIyKseA9O LKfQ== X-Gm-Message-State: APjAAAWk4XqOyiL+ryT1Kmobk/Yf+yKj7t512bruo4ZiOwShLbBX19/S 1ZYGua2ZuGYZENatnbELXr0okOhS5AY= X-Google-Smtp-Source: APXvYqyQV4XKkiw3QvCltYj+XWfmNU/ArJFvwr2z079vCKUsCH867nnYVWi/v2LESjP7sx7U8OVIAQ== X-Received: by 2002:a63:7207:: with SMTP id n7mr12979287pgc.253.1582182247586; Wed, 19 Feb 2020 23:04:07 -0800 (PST) Return-Path: Received: from localhost.localdomain ([223.104.4.131]) by smtp.gmail.com with ESMTPSA id 84sm2139486pgg.90.2020.02.19.23.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 23:04:06 -0800 (PST) From: "GuoMinJ" To: devel@edk2.groups.io Cc: GuoMinJ Subject: [PATCH] MdeModulePkg/Application: Overflowed Array Index Date: Thu, 20 Feb 2020 15:01:47 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2272 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2289 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2290 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2287 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2288 Index should be off-by one than size of array, so when check array, the max index should less than size of array. Signed-off-by: GuoMinJ --- .../SmiHandlerProfileInfo/SmiHandlerProfileInfo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c index 0f7163160b..4f195b16ce 100644 --- a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c +++ b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c @@ -382,7 +382,7 @@ SxTypeToString ( IN EFI_SLEEP_TYPE Type ) { - if (Type >= 0 && Type <= ARRAY_SIZE(mSxTypeString)) { + if (Type >= 0 && Type < ARRAY_SIZE(mSxTypeString)) { return mSxTypeString[Type]; } else { AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type); @@ -407,7 +407,7 @@ SxPhaseToString ( IN EFI_SLEEP_PHASE Phase ) { - if (Phase >= 0 && Phase <= ARRAY_SIZE(mSxPhaseString)) { + if (Phase >= 0 && Phase < ARRAY_SIZE(mSxPhaseString)) { return mSxPhaseString[Phase]; } else { AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase); @@ -457,7 +457,7 @@ StandbyButtonPhaseToString ( IN EFI_STANDBY_BUTTON_PHASE Phase ) { - if (Phase >= 0 && Phase <= ARRAY_SIZE(mStandbyButtonPhaseString)) { + if (Phase >= 0 && Phase < ARRAY_SIZE(mStandbyButtonPhaseString)) { return mStandbyButtonPhaseString[Phase]; } else { AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase); @@ -483,7 +483,7 @@ IoTrapTypeToString ( IN EFI_SMM_IO_TRAP_DISPATCH_TYPE Type ) { - if (Type >= 0 && Type <= ARRAY_SIZE(mIoTrapTypeString)) { + if (Type >= 0 && Type < ARRAY_SIZE(mIoTrapTypeString)) { return mIoTrapTypeString[Type]; } else { AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type); @@ -508,7 +508,7 @@ UsbTypeToString ( IN EFI_USB_SMI_TYPE Type ) { - if (Type >= 0 && Type <= ARRAY_SIZE(mUsbTypeString)) { + if (Type >= 0 && Type < ARRAY_SIZE(mUsbTypeString)) { return mUsbTypeString[Type]; } else { AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type); -- 2.17.1