[edk2] [Patch 1/4] BaseTools/VolInfo: Update OPENSSL_PATH to support space characters

Yonghong Zhu posted 4 patches 7 years, 8 months ago
[edk2] [Patch 1/4] BaseTools/VolInfo: Update OPENSSL_PATH to support space characters
Posted by Yonghong Zhu 7 years, 8 months ago
Update OPENSSL_PATH handling to support space characters in the Path.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c
index eff5f9e..a695529 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -329,11 +329,14 @@ Returns:
       OpenSslCommand = "openssl";
       OpenSslEnv = getenv("OPENSSL_PATH");
       if (OpenSslEnv == NULL) {
         OpenSslPath = OpenSslCommand;
       } else {
-        OpenSslPath = malloc(strlen(OpenSslEnv)+strlen(OpenSslCommand)+1);
+        //
+        // We add quotes to the Openssl Path in case it has space characters
+        //
+        OpenSslPath = malloc(2+strlen(OpenSslEnv)+strlen(OpenSslCommand)+1);
         if (OpenSslPath == NULL) {
           Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
           return GetUtilityStatus ();
         }
         CombinePath(OpenSslEnv, OpenSslCommand, OpenSslPath);
@@ -1589,15 +1592,16 @@ CombinePath (
   OUT CHAR8* NewPath
 )
 {
   UINT32 DefaultPathLen;
   UINT64 Index;
-
+  CHAR8  QuotesStr[] = "\"";
+  strcpy(NewPath, QuotesStr);
   DefaultPathLen = strlen(DefaultPath);
-  strcpy(NewPath, DefaultPath);
+  strcat(NewPath, DefaultPath);
   Index = 0;
-  for (; Index < DefaultPathLen; Index ++) {
+  for (; Index < DefaultPathLen + 1; Index ++) {
     if (NewPath[Index] == '\\' || NewPath[Index] == '/') {
       if (NewPath[Index + 1] != '\0') {
         NewPath[Index] = '/';
       }
     }
@@ -1605,10 +1609,11 @@ CombinePath (
   if (NewPath[Index -1] != '/') {
     NewPath[Index] = '/';
     NewPath[Index + 1] = '\0';
   }
   strcat(NewPath, AppendPath);
+  strcat(NewPath, QuotesStr);
   return EFI_SUCCESS;
 }
 
 EFI_STATUS
 ParseSection (
-- 
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel