Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2004, 09:37 AM
Merth
Dragon
 
Join Date: May 2003
Location: Seattle, WA
Posts: 609
Default Signed/Unsigned comparisons

There's a lot of warnings that pop up in my compiler for the eqemu code regarding comparisons between signed and unsigned integers. For this type of project, it's not a huge deal - but it is worth noting what kind of things can result from this problem.

Today on slashdot, there was an article showing exactly what can happen. The Microsoft code leaked last week showed a vulnerability in IE5 that allows a remote user to execute arbitrary code on the target system. The URL for reference is http://www.securitytracker.com/alert...b/1009067.html.

Here's the important part:
Quote:
Code:
    // Before we read the bits, seek to the correct location in the file
    while (_bmfh.bfOffBits > (unsigned)cbRead)
    {
        BYTE abDummy[1024];
        int cbSkip;

        cbSkip = _bmfh.bfOffBits - cbRead;
        
        if (cbSkip > 1024)
            cbSkip = 1024;

        if (!Read(abDummy, cbSkip))
            goto Cleanup;
            
        cbRead += cbSkip;
    }
.. Rrrrriiiiggghhhttt. Way to go, using a signed integer for an
offset. Now all we have to do is create a BMP with bfOffBits > 2^31,

and we're in. cbSkip goes negative and the Read call clobbers the
stack with our data.

See attached for proof of concept. index.html has [img src=1.bmp]
where 1.bmp contains bfOffBits=0xEEEEEEEE plus 4k of 0x44332211.
Bring it up in IE5 (tested successfully on Win9 and get
EIP=0x44332211.
Morale of the story: Pay attention to what kind of datatypes you are using!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 03:56 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3