Thread overview
[Issue 961] New: std.windows.registry stack corruption
Feb 14, 2007
d-bugmail
Feb 14, 2007
d-bugmail
Aug 12, 2007
d-bugmail
Aug 12, 2007
d-bugmail
Sep 29, 2007
d-bugmail
February 14, 2007
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>


-- 

February 14, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=961





------- Comment #1 from technocrat7@gmail.com  2007-02-14 00:24 -------
Created an attachment (id=101)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=101&action=view)
Jay Jacobson's proposed fix


-- 

August 12, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=961





------- Comment #2 from bugzilla@digitalmars.com  2007-08-12 14:08 -------
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.


-- 

August 12, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=961





------- Comment #3 from bugzilla@digitalmars.com  2007-08-12 14:33 -------
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.


-- 

September 29, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=961


bugzilla@digitalmars.com changed:

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




------- Comment #4 from bugzilla@digitalmars.com  2007-09-28 22:05 -------
Fixed dmd 1.021 and 2.004


--