PDA

View Full Version : Bug: Integer overflow in Registry GetValue/SetValue


adrien
03-24-2009, 10:07 PM
Hi

I've some lua code that I use to copy registry keys in my installer.

I'm finding it's converting any REG_DWORD value of 0xFFFFFFFE to 0x7FFFFFF

everything else copies fine, just these large DWORDs.

My guess is it's converting any value > max signed int to max signed int.

Either that or the set value is incorrectly dealing with sign.

The copy function is as below

function CopyRegKey(rootkey, source, dest, bDeleteOld)
-- create target key
Registry.CreateKey(rootkey, dest);
-- recursively iterate subkeys
subkeys = Registry.GetKeyNames(rootkey, source);
if(subkeys ~= nil) then
for ind, keyname in pairs(subkeys) do
CopyRegKey(rootkey, source.."\\"..keyname, dest.."\\"..keyname, bDeleteOld);
end
end
-- copy the values over
values = Registry.GetValueNames(rootkey, source);
if(values ~= nil) then
for ind, valname in pairs(values) do
-- get data and type from source value
v = Registry.GetValue(rootkey, source, valname, false);
t = Registry.GetValueType(rootkey, source, valname);
-- poke the value into the target key
Registry.SetValue(rootkey, dest, valname, v, t);
end
end

-- ok, no subkeys or values in this source key, delete it
if(bDeleteOld== true)then
Registry.DeleteValue(rootkey, source, "(Default)");
Registry.DeleteKey(rootkey, source);
end
end

I've patched around it in my code, but it's an ugly hack. Someone might want to fix this in next SetupFactory or Lua.

Ulrich
03-25-2009, 11:52 AM
Hello,

thank you for the report. This has been entered into our internal bug tracking database.

Reference number: 18425.

Regards,
Ulrich

adrien
03-25-2009, 09:59 PM
thanks

I had to fix the problem quick, so I wrote an action module for it which I just submitted.

those functions really should be part of Registry.

I can give you source if you like.

Regards

Adrien