From patchwork Fri Jun 17 08:58:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 636838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3rWDgh3bg9z9t21; Fri, 17 Jun 2016 18:58:40 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1bDpbp-0007GK-Ct; Fri, 17 Jun 2016 08:58:37 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1bDpbk-0007GB-2K for fwts-devel@lists.ubuntu.com; Fri, 17 Jun 2016 08:58:32 +0000 Received: from [175.41.48.77] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1bDpbj-0000GP-6F; Fri, 17 Jun 2016 08:58:31 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] uefirtvariable: modify getnextvariablename test for VariableNameSize smaller than 2 (LP: #1593597) Date: Fri, 17 Jun 2016 16:58:26 +0800 Message-Id: <1466153906-23285-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com Some firmwares (mostly on AMI Bios), the implementation limitation was seen that the VariableNameSize of the GetNextVariableName should lager or equal to 2. They believe that it should at least have a Null-terminated(2 bytes) for the name buffer. So test getnextvariablename with VariableNameSize 0 and 1 will get the EFI_INVALID_PARAMETER, not expected EFI_BUFFER_TOO_SMALL. UEFI spec doesn't describe it clearly, VariableName is the Null-treminated string, so the EFI_INVALID_PARAMETER seems also a resonable return when VariableNameSize smaller than 2. Before the spec has a clearly description, for the fwts getnextvariablename buffer too small test(getnextvariable_test4), 1. add the VariableNameSize 2 for the test, if VariableNameSize 2 without returning EFI_BUFFER_TOO_SMALL, then test fail. 2. if VariableNameSize is 0 or 1, allow the extra return EFI_INVALID_PARAMETER. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtvariable/uefirtvariable.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index 0514805..aca0202 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -812,8 +812,7 @@ static int getnextvariable_test4(fwts_framework *fw) goto err; } - /* No first result can be 0 or 1 byte in size. */ - for (i = 0; i < 2; i++) { + for (i = 0; i < 3; i++) { variablenamesize = i; getnextvariablename.VariableNameSize = &variablenamesize; @@ -831,6 +830,8 @@ static int getnextvariable_test4(fwts_framework *fw) * EFI_NOT_FOUND at this point. */ if (ioret != -1 || status != EFI_BUFFER_TOO_SMALL) { + if (i != 2 && status == EFI_INVALID_PARAMETER) + continue; fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextVariableName", "Expected EFI_BUFFER_TOO_SMALL with small "