From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=lyjYxMCo; spf=pass (domain: linaro.org, ip: 209.85.128.65, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by groups.io with SMTP; Mon, 10 Jun 2019 07:20:19 -0700 Received: by mail-wm1-f65.google.com with SMTP id 22so8354759wmg.2 for ; Mon, 10 Jun 2019 07:20:19 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=qItUgN4lcj6cFdjihisW4+QV4TBoAdJy6uds0FJXVZI=; b=lyjYxMCoX+zLASs7q1PdwF/FcDSJNoPAVtr6E+Ap9h3r8L8hP9VBK4BBsdCeuireX6 V/h6QwHsV0uPlC+r27sLa1K8APtlBzu34Vnd8TSdConPqlpZNSCJSraSMEUofJcWXUjZ SC6GLdV5GQy/7Pk1M3oHcxLsrXBorOgkGq7Qv3uR19HSCsNdojAu4s6BTrwhhw5QYocB pUy+OQh5tvq3P0Ow/flJ/4bshaTnMgfdO6ky65axwCYzz2K3gojnUu0bcvgMtOLJwTNN eEKCZyIOaQmXQ49Qji/71BfXI2TDUImM6wrW3ht3LTqSzvNvWMpq1/O/z7nJtJXvDfJf LpNw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=qItUgN4lcj6cFdjihisW4+QV4TBoAdJy6uds0FJXVZI=; b=PuLutEujbbfClzzrDh9NWG+oMYI5WUj2/nL7DVjdUVYLtbCiF55b89fq0qwCR0aOME pq8aY+63QKDBQttOkdA1/z6+y0iZKZC8H7ILP3roXwKkUAY/Z+w0TcuRVZ9xjQm64vLY 7HKQbWv/pAASkIVEI9bncwHuoXe+RpOwqSmjmVzgYyk23/I7isOGcAdwVhWBhtYhbRza zyrivsSkvCLrDDatqv8agVm3AVZcKe2MRPbvYZsys0ZoyzGnIfEIaxhc83kr3ojnGMly dzPDKrtb6laHs9zaSDurhXiV504NfG/fcxsqpinLfU9gOPmGGnxf3efKmtzzHilOuwV4 SyEw== X-Gm-Message-State: APjAAAWC6/79ovkVL3pOudhKfmV/abdiR/AuqJbd5yh2fZuzhkYcBQu1 qSEoCUASaqAx0f2ZLF2mNNXYegN9ES+fxQ== X-Google-Smtp-Source: APXvYqz8YWMcvfji7MmvadfM2e6YchPUJaIbJuJ1OS2UTczQFzwbLFH7tygo+Dmjsx2PIZSaftuY3w== X-Received: by 2002:a7b:cb01:: with SMTP id u1mr15071434wmj.153.1560176417703; Mon, 10 Jun 2019 07:20:17 -0700 (PDT) Return-Path: Received: from sudo.home ([2a01:cb1d:112:6f00:fc6b:c1c2:30ed:eca3]) by smtp.gmail.com with ESMTPSA id z5sm9237693wma.36.2019.06.10.07.20.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jun 2019 07:20:17 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH edk2-platforms 5/5] Platform/RDKQemu: stop using deprecated string conversion routines Date: Mon, 10 Jun 2019 16:20:06 +0200 Message-Id: <20190610142006.30007-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610142006.30007-1-ard.biesheuvel@linaro.org> References: <20190610142006.30007-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Stop using deprecated string conversion routines so we can stop un'#define'ing the DISABLE_NEW_DEPRECATED_INTERFACES macro in this code. Signed-off-by: Ard Biesheuvel --- Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c | 12 +++++++-- Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c | 28 +++++++++++--------- Platform/Comcast/RDKQemu/RDKQemu.dsc | 3 --- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c b/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c index ed893bd5af6a..df16c326cc57 100644 --- a/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c +++ b/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c @@ -90,6 +90,7 @@ ListBlockIos ( UINTN NumHandles; UINT16 *DeviceFullPath; DISKIO_PARTITION_LIST *Entry; + RETURN_STATUS RetStatus; InitializeListHead (&mPartitionListHead); @@ -146,11 +147,13 @@ ListBlockIos ( // Copy handle and partition name Entry->PartitionHandle = AllHandles[LoopIndex]; - StrnCpy ( + RetStatus = StrnCpyS ( Entry->PartitionName, + PARTITION_NAME_MAX_LENGTH, PartitionName, PARTITION_NAME_MAX_LENGTH ); + ASSERT_RETURN_ERROR (RetStatus); InsertTailList (&mPartitionListHead, &Entry->Link); break; } @@ -176,8 +179,13 @@ OpenPartition ( DISKIO_PARTITION_LIST *Entry; SPARSE_HEADER *SparseHeader; UINT16 UnicodePartitionName[100]; + RETURN_STATUS RetStatus; - AsciiStrToUnicodeStr ( PartitionName, UnicodePartitionName); + RetStatus = AsciiStrToUnicodeStrS (PartitionName, UnicodePartitionName, + sizeof (UnicodePartitionName)); + if (RETURN_ERROR (RetStatus)) { + return EFI_OUT_OF_RESOURCES; + } DEBUG((DEBUG_INFO, "Unicode partition name %s\n", UnicodePartitionName)); Status = ListBlockIos (UnicodePartitionName); diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c b/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c index dd695651026a..6f98562eff84 100644 --- a/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c +++ b/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c @@ -8,8 +8,6 @@ #define MAX_VAR 6 -#define ALLOCATE_STRING_MEM(X) AllocateZeroPool((X + 1) * sizeof(CHAR16)) - /** * list_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop cursor. @@ -53,10 +51,13 @@ SaveString ( IN CHAR16 *String2 ) { - *Dest = ALLOCATE_STRING_MEM (StrLen (String1) + StrLen (String2)); + UINTN StringLength; + + StringLength = StrLen (String1) + StrLen (String2) + 1; + *Dest = AllocatePool (StringLength * sizeof(CHAR16)); ASSERT (Dest != NULL); - StrCat (*Dest, String1); - StrCat (*Dest, String2); + StrCpyS (*Dest, StringLength, String1); + StrCatS (*Dest, StringLength, String2); } STATIC @@ -74,11 +75,13 @@ LsFiles ( BOOLEAN NoFile; CHAR16 *TempPath; DIR_NODE *Node; + UINTN StringLength; NoFile = FALSE; - TempPath = ALLOCATE_STRING_MEM (StrLen(DirPath) + 1); - StrCat (TempPath, DirPath); - StrCat (TempPath, L"/"); + StringLength = StrLen(DirPath) + 2; + TempPath = AllocatePool (StringLength * sizeof(CHAR16)); + StrCpyS (TempPath, StringLength, DirPath); + StrCatS (TempPath, StringLength, L"/"); Status = GetFileHandler (&FileHandle, DirPath, EFI_FILE_MODE_READ); ASSERT_EFI_ERROR (Status); @@ -192,6 +195,7 @@ InitVarList ( UINTN Next; CHAR8 *VarDelimiter[2]; EFI_STATUS Status; + UINTN StringLength; VarDelimiter[0] = "="; VarDelimiter[1] = "\""; @@ -212,10 +216,10 @@ InitVarList ( if (VarResult[OuterLoopIndex][InnerLoopIndex]) { FreePool (VarResult[OuterLoopIndex][InnerLoopIndex]); } - VarResult[OuterLoopIndex][InnerLoopIndex] = \ - ALLOCATE_STRING_MEM (AsciiStrLen (&FileData[Current])); - AsciiStrToUnicodeStr (&FileData[Current], \ - VarResult[OuterLoopIndex][InnerLoopIndex]); + StringLength = AsciiStrLen (&FileData[Current]) + 1; + VarResult[OuterLoopIndex][InnerLoopIndex] = AllocatePool (StringLength); + AsciiStrToUnicodeStrS (&FileData[Current], + VarResult[OuterLoopIndex][InnerLoopIndex], StringLength); //skip new line Next += 2; } diff --git a/Platform/Comcast/RDKQemu/RDKQemu.dsc b/Platform/Comcast/RDKQemu/RDKQemu.dsc index f0ed4f11e81d..440d2ace917c 100644 --- a/Platform/Comcast/RDKQemu/RDKQemu.dsc +++ b/Platform/Comcast/RDKQemu/RDKQemu.dsc @@ -418,6 +418,3 @@ [Components.AARCH64] NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf } - -[BuildOptions] - GCC:*_*_*_CC_FLAGS = -UDISABLE_NEW_DEPRECATED_INTERFACES -- 2.20.1