Re: why dosent buffer gets overflowed



raashid bhatt said:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void func(char *p)
{
char i[5];
strcpy(i, p);

Subject line: "why dosent buffer gets overflowed"

What makes you think the buffer isn't being overflowed?

}

int main(int argc, char **argv)
{

func("AAAAAAAAAA"); // i have supplied 2 X 5 char to it

Then you're trying to store more data in the array than it has room for,
and you don't provide any safeguards against that, so you're overflowing
that buffer, and the result is that the program exhibits undefined
behaviour - i.e. the rules of C don't tell you what will happen.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Detailed analysis: Buffer overflow in Explorer.exe on Windows XP SP1
    ... Actually, I assume the overflowing file, no matter where it is located in ... it assumes the buffer to be as ... We do not know how this bug affects shell32.dll files on other Windows ... unintentionally execute arbitrary code. ...
    (Bugtraq)
  • Re: Ancient history
    ... >> the boundary is between overflowing and access to an extended area ... Changing from the fixed sized queues implemented using an array ... When an entry is made a buffer is requested from the heap. ... paragraph for every line he writes. ...
    (sci.crypt)
  • Re: DEFCON 16 and Hacking OpenVMS
    ... SMG is written in BLISS. ... correctly) is not overflowing the buffer because a null is missing. ... code longer than DEFCONs have been around. ...
    (comp.os.vms)
  • Re: classes and using *
    ... > I've never heard of any city with more than 255 characters, ... Overflowing a buffer is one of the ...
    (comp.lang.cpp)
  • Re: Cannot return values of char variable
    ... - buffer = ... Since you seem to be trying to return a char pointer ... int id = random; ... content is interpreted as a string. ...
    (comp.lang.c)