Discussion:
[edk2] [PATCH 09/13] MdeModulePkg/Universal/FvSimpleFileSystemDxe: Use safe string functions to refine code.
Qiu Shumin
2015-06-25 07:47:00 UTC
Permalink
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
---
.../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
index 019be26..b0e7dc3 100644
--- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
+++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
@@ -12,7 +12,7 @@
from the UEFI shell. It is entirely read-only.

Copyright (c) 2014, ARM Limited. All rights reserved.
-Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>

This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -898,7 +898,11 @@ FvSimpleFileSystemGetInfo (
FsInfoOut = (EFI_FILE_SYSTEM_INFO *) Buffer;

CopyMem (FsInfoOut, &mFsInfoTemplate, sizeof (EFI_FILE_SYSTEM_INFO));
- Status = StrnCpyS (FsInfoOut->VolumeLabel, (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_INFO, VolumeLabel)) / sizeof (CHAR16), Instance->VolumeLabel, StrLen (Instance->VolumeLabel));
+ Status = StrnCpyS ( FsInfoOut->VolumeLabel,
+ (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_INFO, VolumeLabel)) / sizeof (CHAR16),
+ Instance->VolumeLabel,
+ StrLen (Instance->VolumeLabel)
+ );
ASSERT_EFI_ERROR (Status);
FsInfoOut->Size = Size;
return Status;
@@ -919,7 +923,11 @@ FvSimpleFileSystemGetInfo (
}

FsVolumeLabel = (EFI_FILE_SYSTEM_VOLUME_LABEL*) Buffer;
- Status = StrnCpyS (FsVolumeLabel->VolumeLabel, (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_VOLUME_LABEL, VolumeLabel)) / sizeof (CHAR16), Instance->VolumeLabel, StrLen (Instance->VolumeLabel));
+ Status = StrnCpyS (FsVolumeLabel->VolumeLabel,
+ (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_VOLUME_LABEL, VolumeLabel)) / sizeof (CHAR16),
+ Instance->VolumeLabel,
+ StrLen (Instance->VolumeLabel)
+ );
ASSERT_EFI_ERROR (Status);
return Status;
} else {
--
1.9.5.msysgit.1
Ni, Ruiyu
2015-06-29 06:34:41 UTC
Permalink
-----Original Message-----
From: Qiu, Shumin
Sent: Thursday, June 25, 2015 3:47 PM
Cc: Zeng, Star; Fan, Jeff; Gao, Liming; Ni, Ruiyu; Tian, Feng
Use safe string functions to refine code.
Contributed-under: TianoCore Contribution Agreement 1.0
---
.../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git
a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
index 019be26..b0e7dc3 100644
---
a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
+++
b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
@@ -12,7 +12,7 @@
from the UEFI shell. It is entirely read-only.
Copyright (c) 2014, ARM Limited. All rights reserved.
-Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -898,7 +898,11 @@ FvSimpleFileSystemGetInfo (
FsInfoOut = (EFI_FILE_SYSTEM_INFO *) Buffer;
CopyMem (FsInfoOut, &mFsInfoTemplate, sizeof
(EFI_FILE_SYSTEM_INFO));
- Status = StrnCpyS (FsInfoOut->VolumeLabel, (*BufferSize - OFFSET_OF
(EFI_FILE_SYSTEM_INFO, VolumeLabel)) / sizeof (CHAR16),
Instance->VolumeLabel, StrLen (Instance->VolumeLabel));
+ Status = StrnCpyS ( FsInfoOut->VolumeLabel,
+ (*BufferSize - OFFSET_OF
(EFI_FILE_SYSTEM_INFO, VolumeLabel)) / sizeof (CHAR16),
+ Instance->VolumeLabel,
+ StrLen (Instance->VolumeLabel)
+ );
ASSERT_EFI_ERROR (Status);
FsInfoOut->Size = Size;
return Status;
@@ -919,7 +923,11 @@ FvSimpleFileSystemGetInfo (
}
FsVolumeLabel = (EFI_FILE_SYSTEM_VOLUME_LABEL*) Buffer;
- Status = StrnCpyS (FsVolumeLabel->VolumeLabel, (*BufferSize
- OFFSET_OF (EFI_FILE_SYSTEM_VOLUME_LABEL, VolumeLabel)) / sizeof
(CHAR16), Instance->VolumeLabel, StrLen (Instance->VolumeLabel));
+ Status = StrnCpyS (FsVolumeLabel->VolumeLabel,
+ (*BufferSize - OFFSET_OF
(EFI_FILE_SYSTEM_VOLUME_LABEL, VolumeLabel)) / sizeof (CHAR16),
+ Instance->VolumeLabel,
+ StrLen (Instance->VolumeLabel)
+ );
ASSERT_EFI_ERROR (Status);
return Status;
} else {
--
1.9.5.msysgit.1
Loading...