[edk2-devel] Uefi functions AddUnicodeString2() and LookupUnicodeString2() are returning EFI_UNSUPPORTED incorrectly

chandramohan.akula via groups.io posted 1 patch 3 years, 1 month ago
Failed in applying to current master (apply log)
[edk2-devel] Uefi functions AddUnicodeString2() and LookupUnicodeString2() are returning EFI_UNSUPPORTED incorrectly
Posted by chandramohan.akula via groups.io 3 years, 1 month ago
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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#71302): https://edk2.groups.io/g/devel/message/71302
Mute This Topic: https://groups.io/mt/80401075/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-