Security Basics mailing list archives

RE: question about malloc()


From: "Goran Pizent" <goran.pizent () ekobit hr>
Date: Thu, 15 Sep 2005 15:42:48 +0200

Well you are trying to allocate about 1 GB of memory in one big block.
That's why your example hangs on the malloc() line.

Do you really have that much of RAM on your machine?

What kind of exploit are you trying to apply?

My 2c,

GoranP



-----Original Message-----
From: Seung Hyun Cho [mailto:s970501 () gmail com] 
Sent: Wednesday, September 14, 2005 2:14 PM
To: security-basics () securityfocus com
Subject: question about malloc()

Hi,

I am studying on exploitation. 
But my knowldge of c programming is very limited.
I studied c language 10 yrs ago and never used it.
Now i am having some problems.

I have a question about exploit example of my book.

----------------------------------
...
char *buf;
buf = malloc(1<<30);
fgets(buf, 1024, stdin);
printf("%s\n", buf);
...
----------------------------------

Can anyone explain this? This should be very simple...
when I put buf = malloc(1<<29), it is working...

What is going on here...?

help~


Current thread: