Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Determing the area of a set of rectangles Pin
Christian Graus3-Mar-04 16:45
protectorChristian Graus3-Mar-04 16:45 
GeneralRe: Determing the area of a set of rectangles Pin
Gary R. Wheeler3-Mar-04 16:52
Gary R. Wheeler3-Mar-04 16:52 
GeneralRe: Determing the area of a set of rectangles Pin
Christian Graus3-Mar-04 17:34
protectorChristian Graus3-Mar-04 17:34 
GeneralRe: Determing the area of a set of rectangles Pin
Filousov5-Mar-04 13:36
Filousov5-Mar-04 13:36 
GeneralBuffer Overflow's Pin
Frank Deo3-Mar-04 13:13
Frank Deo3-Mar-04 13:13 
GeneralRe: Buffer Overflow's Pin
Prakash Nadar3-Mar-04 13:35
Prakash Nadar3-Mar-04 13:35 
GeneralRe: Buffer Overflow's Pin
Steve S4-Mar-04 6:13
Steve S4-Mar-04 6:13 
GeneralRe: Buffer Overflow's Pin
Mike Dimmick4-Mar-04 6:29
Mike Dimmick4-Mar-04 6:29 
A buffer overflow is simply when you write past the end of a buffer. This typically means that you overwrite whatever was on the stack before the buffer. The major problem here is how the program stack is organised on an x86 system. The return address of a called function is stored on the stack by the CALL instruction. Overwriting the return address can cause the program to jump to a different address. If the attacker knows where the buffer is located in memory, he can write program code to the buffer, and cause the program to jump to an address in the buffer, executing the code he put there. Strictly speaking this is a stack buffer overflow.

The return address gets overwritten because the stack grows downwards in memory (towards lower addresses), whereas string operations proceed upwards in memory (towards higher addresses).

It's also possible to cause a heap buffer overflow, but this is usually less serious. However, if the attacker manages to overwrite a C++ object's vtable pointer, and the program calls a virtual function, he can again redirect the program's execution.

You can avoid buffer overflows by checking your buffer code. Be wary of calls to strcpy or any other function that performs an uncounted copy operation. Check that the sizes you've passed to counted copy operations are correct - some Windows functions take counts of elements, while others take counts of bytes. If you're working with WCHARs or TCHARs, remember that they can be 2 bytes in size (and therefore you need to divide the result of sizeof by sizeof(WCHAR) for an element-oriented function).

If you ensure that you only ever write an amount of data less than or equal to the size of the buffer, you will never have a buffer overflow.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Buffer Overflow's Pin
Frank Deo4-Mar-04 11:37
Frank Deo4-Mar-04 11:37 
GeneralAVI FIles Pin
Anonymous3-Mar-04 12:20
Anonymous3-Mar-04 12:20 
GeneralProcessing messages Pin
ffazly3-Mar-04 11:48
ffazly3-Mar-04 11:48 
GeneralRe: Processing messages Pin
rrrado4-Mar-04 6:28
rrrado4-Mar-04 6:28 
GeneralDeprecated files in \MS Visual Studio\VC98 Pin
john john mackey3-Mar-04 11:13
john john mackey3-Mar-04 11:13 
GeneralMFC dialog member sharing? (code included) Pin
Christophocles3-Mar-04 11:12
sussChristophocles3-Mar-04 11:12 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 5:10
BlackDice4-Mar-04 5:10 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 5:44
sussChristophocles4-Mar-04 5:44 
GeneralRe: MFC dialog member sharing? (code included) Pin
monrobot134-Mar-04 5:39
monrobot134-Mar-04 5:39 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 5:49
sussChristophocles4-Mar-04 5:49 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 6:07
BlackDice4-Mar-04 6:07 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 7:06
sussChristophocles4-Mar-04 7:06 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 8:23
BlackDice4-Mar-04 8:23 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 9:14
sussChristophocles4-Mar-04 9:14 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 9:30
BlackDice4-Mar-04 9:30 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 10:27
sussChristophocles4-Mar-04 10:27 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice5-Mar-04 3:49
BlackDice5-Mar-04 3:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.