From 3337eefb49d9053cfd75028ab74dad0cd7acd045 Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Wed, 19 Apr 2017 17:50:00 +0800 Subject: [PATCH] BaseTools/VolInfo: Update OPENSSL_PATH to support space characters Update OPENSSL_PATH handling to support space characters in the Path. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- 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 eff5f9ebfc..a695529b8a 100644 --- a/BaseTools/Source/C/VolInfo/VolInfo.c +++ b/BaseTools/Source/C/VolInfo/VolInfo.c @@ -331,7 +331,10 @@ Returns: 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 (); @@ -1591,11 +1594,12 @@ CombinePath ( { 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] = '/'; @@ -1607,6 +1611,7 @@ CombinePath ( NewPath[Index + 1] = '\0'; } strcat(NewPath, AppendPath); + strcat(NewPath, QuotesStr); return EFI_SUCCESS; } -- 2.39.2