OLEAUT32: VARIANT parsing of hex/octal integer string must not negate
value
Alex Villacis Lasso
a_villacis at palosanto.com
Mon Jan 10 09:52:01 CST 2005
This patch was originally to fix a bug in which Visual Basic 6 attempts
to parse the following statement:
Dim someValue As Long = &H80000002
by feeding it to the VARIANT parsing routines. The purpose of the
previous statement is to build a 32-bit signed value whose bit pattern
is 0x80000002. This succeeds in Windows, but fails in Wine with an
overflow, which is reported to the VB6 user as a "parse error". Upon
examination of dlls/oleaut32/variant.c, I realized that there is a
verification of upper and lower bounds before assigning the VT_I4 value.
However, this check is incorrect in at least two places:
* The check for a valid VT_I4 fails for the hex pattern shown above,
because the value, if interpreted as unsigned, requires more than 32
bits, but the negated value in 64 bits does not pass the I4_MIN test either.
* Even if the test succeeded, the programmer's intent was to build an
integer with a specific bit pattern. This intent is broken when the
VARIANT routines assign a negated value rather than the specified bit
pattern.
The attached patch allows Visual Basic to parse the example statement
successfully with the builtin oleaut32.
Please inform whether this patch is adequate or not. If not adequate,
please explain the rationale behind the old behavior.
PS: I have left in place the R_4 and R_8 conversions, since I don't know
whether there is any program which specifies an hex/octal bit pattern
for a floating-point value.
Changelog:
* When parsing an hex/oct integer value, copy value verbatim in VARIANT,
rather than a negated value
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_variant_no_negate_hex.patch
Type: text/x-patch
Size: 2273 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20050110/7fcd046a/patch_variant_no_negate_hex.bin
More information about the wine-patches
mailing list