[PATCH] oleaut32: Fix QueryPathOfRegTypeLib minor version comparison.
Kevin Puetz
PuetzKevinA at JohnDeere.com
Sat Feb 19 14:06:21 CST 2022
A search with wMin != 0xFFFF should match only if the actual version found
matches the major and is is >= the minor version requested (preferring
an exact match if one is available)
Signed-off-by: Kevin Puetz <PuetzKevinA at JohnDeere.com>
--
Wine's RegisterTypeLib and QueryPathOfRegTypeLib format typelib version
in the registery keys as hex. This appears to be correct.
However, do_typelib_reg_key in oleaut32/tests was inconsistent with this
and formatted them in decimal. This caused the 3.40 test case to not be
checking what it meant to; it *should* failing because there is nothing
registered >= 3.40. But it succeeded because we had actually registered
the string "3.37", which means 0x37 == 3.55 (which meets >= 3.40).
This didn't trip up the other cases becuase 1 == 0x1. and 0x22 == 34 <= 3.37.
so their choice between 3.0,3.1, and 3.37 still reached the same answer.
This seems to have just been a latent bug (in the test) all the way
back to the introduction of the test in a1914dbbb8. do_typelib_reg_key
got overlooked when wine was fixed to match windows and format these
in hex in a59e4899f5, and this hex-vs-decimal mismatch vs windows
hid the version-comparison bug.
---
dlls/oleaut32/tests/typelib.c | 4 ++--
dlls/oleaut32/typelib.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c
index 4266243c1ba..6bfc50642a4 100644
--- a/dlls/oleaut32/tests/typelib.c
+++ b/dlls/oleaut32/tests/typelib.c
@@ -1521,7 +1521,7 @@ cleanup:
static BOOL do_typelib_reg_key(GUID *uid, WORD maj, WORD min, DWORD arch, LPCWSTR base, BOOL remove)
{
static const WCHAR typelibW[] = {'T','y','p','e','l','i','b','\\',0};
- static const WCHAR formatW[] = {'\\','%','u','.','%','u','\\','0','\\','w','i','n','%','u',0};
+ static const WCHAR formatW[] = {'\\','%','x','.','%','x','\\','0','\\','w','i','n','%','u',0};
static const WCHAR format2W[] = {'%','s','_','%','u','_','%','u','.','d','l','l',0};
WCHAR buf[128];
HKEY hkey;
@@ -1578,7 +1578,7 @@ static void test_QueryPathOfRegTypeLib(DWORD arch)
{ 3, 1, S_OK, {'f','a','k','e','_','3','_','1','.','d','l','l',0 } },
{ 3, 22, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
{ 3, 37, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
- { 3, 40, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
+ { 3, 40, TYPE_E_LIBNOTREGISTERED, { 0 } },
{ 0xffff, 0xffff, S_OK, {'f','a','k','e','_','5','_','3','7','.','d','l','l',0 } },
{ 0xffff, 0, TYPE_E_LIBNOTREGISTERED, { 0 } },
{ 3, 0xffff, TYPE_E_LIBNOTREGISTERED, { 0 } },
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index cdc48e9c7fe..7f10bcc968d 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -207,7 +207,7 @@ static BOOL find_typelib_key( REFGUID guid, WORD *wMaj, WORD *wMin )
best_min = v_min;
break; /* exact match */
}
- if (*wMin != 0xffff && v_min > best_min) best_min = v_min;
+ if (*wMin != 0xffff && v_min >= *wMin && v_min > best_min) best_min = v_min;
}
}
len = sizeof(key_name);
--
2.34.1
More information about the wine-devel
mailing list