www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 961] New: std.windows.registry stack corruption

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=961

           Summary: std.windows.registry stack corruption
           Product: D
           Version: unspecified
          Platform: PC
               URL: http://www.digitalmars.com/webnews/newsgroups.php?art_gr
                    oup=digitalmars.D.bugs&article_id=9971
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: technocrat7 gmail.com


Jay Jacobson created a patch that seems to fix some bugs in
std.windows.registry. Without the patch, my registry programs didn't work quite
right, but after applying his patch, my programs worked fine.

<Quote>
The first was on line 691 and had to do with setting the cbData value to be the
size of a DWORD 8. This lead to the odd problem pointed at in the previous
post. This caused all string registry values with a size less than 8 to become
corrupted because the fall-through test of "too small a buffer" was skipped. In
the case of a string, you can't know what the size is in advance without first
calling the function to obtain the correct size to allocate. The subsequent
call then works (the fall-through test).

Unfortunately, the one liner fix caused the DWORD registry entries to not be
read correctly which lead to the addition of the case statement to
appropriately set the "data" variable ptr (might be a better way to do this).

Additionally, I found that the EXPAND_SZ method was not stripping a trailing
NULL from the ExpandEnvironmentStringsA call.
</Quote>


-- 
Feb 13 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=961






Created an attachment (id=101)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=101&action=view)
Jay Jacobson's proposed fix


-- 
Feb 13 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=961






I carefully read the code in Reg_QueryValue_(), and cannot see what the problem
is. If the string length is less than 8, it is stored in u.qw, and 'data'
points to it.

The other problem with EXPAND_SZ noted will be fixed.


-- 
Aug 12 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=961






Ah, I found the problem - for small strings, it's returning a pointer to a
local stack variable, which will cause corruption upon function exit. Will fix.


-- 
Aug 12 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=961


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed dmd 1.021 and 2.004


-- 
Sep 28 2007