From patchwork Thu Jan 15 07:59:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 429269 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 5BF95140285; Thu, 15 Jan 2015 18:59:20 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1YBfKn-0004aD-Ju; Thu, 15 Jan 2015 07:59:17 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1YBfKi-0004a2-5q for fwts-devel@lists.ubuntu.com; Thu, 15 Jan 2015 07:59:12 +0000 Received: from 112-104-144-192.adsl.dynamic.seed.net.tw ([112.104.144.192] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1YBfKh-0000g3-CZ; Thu, 15 Jan 2015 07:59:12 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] uefibootpath: include the null-terminated space in device path length Date: Thu, 15 Jan 2015 15:59:07 +0800 Message-Id: <1421308747-27409-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 1.7.9.5 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 The UEFI spec defined some Device Path, such as the Description String on BIOS Boot Specification Device Path as a null-terminated ASCII string that describes the boot device to a user. Those null-terminated spaces need to be included to the device path length. Signed-off-by: Ivan Hu Acked-by: Keng-Yu Lin Acked-by: Alex Hung --- src/uefi/uefibootpath/uefibootpath.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uefi/uefibootpath/uefibootpath.c b/src/uefi/uefibootpath/uefibootpath.c index 1c11963..6c521e4 100644 --- a/src/uefi/uefibootpath/uefibootpath.c +++ b/src/uefi/uefibootpath/uefibootpath.c @@ -606,7 +606,7 @@ static int uefibootpath_check_dev_path(fwts_framework *fw, fwts_uefi_dev_path *d "The length of File Path Media Device Path is %" PRIu16 " bytes " "is not matching with adding the length of Path String %" PRIu16 " bytes.", len, - (uint16_t)(sizeof(fwts_uefi_file_path_dev_path) + (fwts_uefi_str16len(f->path_name) * sizeof(uint16_t)))); + (uint16_t)(sizeof(fwts_uefi_file_path_dev_path) + ((fwts_uefi_str16len(f->path_name) + 1) * sizeof(uint16_t)))); errors++; break; } @@ -660,12 +660,12 @@ static int uefibootpath_check_dev_path(fwts_framework *fw, fwts_uefi_dev_path *d break; } fwts_uefi_bios_dev_path *b = (fwts_uefi_bios_dev_path *)dev_path; - if (len != (sizeof(fwts_uefi_bios_dev_path) + strlen(b->description))) { + if (len != (sizeof(fwts_uefi_bios_dev_path) + strlen(b->description) + 1)) { fwts_failed(fw, LOG_LEVEL_MEDIUM, "UEFIBiosBootDevPathLength", "The length of BIOS Boot Specification Device Path is %" PRIu16 " bytes " "is not matching with adding the length of Description String %" PRIu16 " bytes.", len, - (uint16_t)(sizeof(fwts_uefi_bios_dev_path) + strlen(b->description))); + (uint16_t)(sizeof(fwts_uefi_bios_dev_path) + strlen(b->description) + 1)); errors++; } break;