Uefi functions AddUnicodeString2() and LookupUnicodeString2() are returning EFI_UNSUPPORTED incorrectly


Chandramohan Akula
 

Hi,

The library functions AddUnicodeString2() and LookupUnicodeString2() defined in UefiLib.c are returning EFI_UNSUPPORTED incorrectly.
These functions are returning EFI_UNSUPPORTED because of not finding the given "Language" in "SupportedLanguages", even though it is part of it.
Actually the function caller passing the supported language as ""en-US;ja-JP;zh-Hans"  and the language as "en-US" to those two functions.
The above two functions are passing arguments incorrectly to the function IsLanguageSupported(). The function IsLanguageSupported() is expecting first argument "SupportedLanguages" and second argument "TargetLanguage".
But these functions are passing "TargetLanguage" as first and "SupportedLanguages" as second one.  Due to this,  IsLanguageSupported() function returns that a given language is not supported

I have filed a bug for this https://bugzilla.tianocore.org/show_bug.cgi?id=3211
And attached the following patch:

diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c
index 835218f982..b6a33a0a48 100644
--- a/MdePkg/Library/UefiLib/UefiLib.c
+++ b/MdePkg/Library/UefiLib/UefiLib.c
@@ -839,7 +839,7 @@ LookupUnicodeString2 (
       SupportedLanguages += 3;
     }
   } else {
-    Found = !IsLanguageSupported(Language, SupportedLanguages);
+    Found = !IsLanguageSupported(SupportedLanguages, Language);
   }
 
 
@@ -1133,7 +1133,7 @@ AddUnicodeString2 (
       SupportedLanguages += 3;
     }
   } else {
-    Found = !IsLanguageSupported(Language, SupportedLanguages);
+    Found = !IsLanguageSupported(SupportedLanguages, Language);
   }
   //
   // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED

Join devel@edk2.groups.io to automatically receive all group messages.