From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (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 999131A1E6B for ; Tue, 25 Oct 2016 11:17:23 -0700 (PDT) Received: by mail-wm0-x234.google.com with SMTP id c78so178352662wme.0 for ; Tue, 25 Oct 2016 11:17:23 -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; bh=Nohp8kkGI4DlrGQkIMfk0YM8DCRfogeYcG+6t9tbwuI=; b=FO3NIE0ezZ0nsUYhZa9iNAcmaR2zDoqRSdCwwh7DaqKzTOFrTSY9Hv+actwNG28EME qQjuOwxDUAF9FpQWI5XXVN9Oif6jgmAiV+wpw9s7VbgBBLJT6Ob2Ew+flavmAMdCkLl9 SXWIFG1P4n1Ai2bEo422hf0fRVpWazTQMHwC0= 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:in-reply-to :references; bh=Nohp8kkGI4DlrGQkIMfk0YM8DCRfogeYcG+6t9tbwuI=; b=U1i3Ic0DIW7+rRdzhwzSXiaMvJHSXVGfVMK4JudUi6FnbG6FF/L7MApDhl034GjY7j SSZsKuupsV9gbLuq8F7W1Px5mVI++zKOf6c8ctrZbyFZQuCAy/jZheUdxUyEecoLRPRk 50hLAcAcAQJlfEMYATkKx8Ha9oNDkYWlyNkB+/uzylgJXZrOvQoMh60yd1ylcXppPS62 P3WvpqZWpJBGMUPNp57LsWpFc1dhummCfgeg4s0YjC3DXaevyhJA5YlCK5UD8YQFFTPt VlPec0IOuuJ2Nb4n0ipp5JMlfoq1bb91hv+60a0OHT7AvacqqA7xEyHM/E0q/JBW6wfb mYzw== X-Gm-Message-State: ABUngvfinKdKHunn2ftZyWTlXdctxw+VQzE1cSHeeEq4jZmdjl4M7XPomDX30jlwaK4HLdpq X-Received: by 10.28.167.214 with SMTP id q205mr4450582wme.21.1477419442211; Tue, 25 Oct 2016 11:17:22 -0700 (PDT) Received: from localhost.localdomain ([105.129.136.43]) by smtp.gmail.com with ESMTPSA id k74sm4993378wmd.18.2016.10.25.11.17.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 11:17:21 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Cc: lersek@redhat.com, Ard Biesheuvel Date: Tue, 25 Oct 2016 19:17:04 +0100 Message-Id: <1477419424-22235-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477419424-22235-1-git-send-email-ard.biesheuvel@linaro.org> References: <1477419424-22235-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [PATCH 2/2] ArmPlatformPkg/BootMonFs: eliminate deprecated string functions 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: Tue, 25 Oct 2016 18:17:24 -0000 Get rid of functions that are no longer available when defining DISABLE_NEW_DEPRECATED_INTERFACES Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c | 8 +++----- ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c | 3 ++- ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c | 12 +++++------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c index 450a707f183c..2736d3e0d0bf 100644 --- a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c +++ b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c @@ -304,7 +304,6 @@ SetFileName ( IN CONST CHAR16 *FileName ) { - CHAR16 TruncFileName[MAX_NAME_LENGTH]; CHAR8 AsciiFileName[MAX_NAME_LENGTH]; BOOTMON_FS_FILE *SameFile; @@ -314,9 +313,7 @@ SetFileName ( FileName++; } - StrnCpy (TruncFileName, FileName, MAX_NAME_LENGTH - 1); - TruncFileName[MAX_NAME_LENGTH - 1] = 0; - UnicodeStrToAsciiStr (TruncFileName, AsciiFileName); + UnicodeStrToAsciiStrS (FileName, AsciiFileName, MAX_NAME_LENGTH); if (BootMonGetFileFromAsciiFileName ( File->Instance, @@ -327,7 +324,8 @@ SetFileName ( return EFI_ACCESS_DENIED; } else { // OK, change the filename. - AsciiStrToUnicodeStr (AsciiFileName, File->Info->FileName); + AsciiStrToUnicodeStrS (AsciiFileName, File->Info->FileName, + (File->Info->Size - sizeof *File->Info) / sizeof (CHAR16)); return EFI_SUCCESS; } } diff --git a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c index 3d71760fef99..a1150856f6ba 100644 --- a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c +++ b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsEntryPoint.c @@ -98,7 +98,8 @@ BootMonGetFileFromAsciiFileName ( { FileEntry = BOOTMON_FS_FILE_FROM_LINK_THIS (Entry); if (FileEntry->Info != NULL) { - UnicodeStrToAsciiStr (FileEntry->Info->FileName, OpenFileAsciiFileName); + UnicodeStrToAsciiStrS (FileEntry->Info->FileName, OpenFileAsciiFileName, + MAX_NAME_LENGTH); AsciiFileNameToCompare = OpenFileAsciiFileName; } else { AsciiFileNameToCompare = FileEntry->HwDescription.Footer.Filename; diff --git a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c index af2fe514f044..4927d987eccf 100644 --- a/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c +++ b/ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsOpenClose.c @@ -101,7 +101,8 @@ WriteFileDescription ( Description->Attributes = 1; Description->BlockStart = FileStart / BlockSize; Description->BlockEnd = Description->BlockStart + (FileSize / BlockSize); - AsciiStrCpy (Description->Footer.Filename, FileName); + AsciiStrCpyS (Description->Footer.Filename, + sizeof Description->Footer.Filename, FileName); #ifdef MDE_CPU_ARM Description->Footer.Offset = HW_IMAGE_FOOTER_OFFSET; @@ -294,7 +295,7 @@ BootMonFsFlushFile ( DiskIo = Instance->DiskIo; BlockSize = Media->BlockSize; - UnicodeStrToAsciiStr (Info->FileName, AsciiFileName); + UnicodeStrToAsciiStrS (Info->FileName, AsciiFileName, MAX_NAME_LENGTH); // If the file doesn't exist then find a space for it if (File->HwDescription.RegionCount == 0) { @@ -626,10 +627,7 @@ BootMonFsOpenFile ( Status = EFI_OUT_OF_RESOURCES; goto Error; } - UnicodeStrToAsciiStr (Path, AsciiFileName); - if (AsciiStrSize (AsciiFileName) > MAX_NAME_LENGTH) { - AsciiFileName[MAX_NAME_LENGTH - 1] = '\0'; - } + UnicodeStrToAsciiStrS (Path, AsciiFileName, MAX_NAME_LENGTH); if ((AsciiFileName[0] == '\0') || (AsciiFileName[0] == '.' ) ) { @@ -688,7 +686,7 @@ BootMonFsOpenFile ( Info->FileSize = BootMonFsGetImageLength (File); Info->PhysicalSize = BootMonFsGetPhysicalSize (File); - AsciiStrToUnicodeStr (AsciiFileName, Info->FileName); + AsciiStrToUnicodeStrS (AsciiFileName, Info->FileName, MAX_NAME_LENGTH); File->Info = Info; Info = NULL; -- 2.7.4