Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Re: Is python buffer overflow proof?

 
Thread Tools Search this Thread
Old 08-02-2009, 04:18 PM   #1
Default Re: Is python buffer overflow proof?


On Sun, 02 Aug 2009 13:50:14 +0000, Jizzai wrote:

> Is a _pure_ python program buffer overflow proof?


It's supposed to be.

> For example in C++ you can declare a char[9] to hold user input. If the
> user inputs 10+ chars a buffer overflow occurs.
>
> In python, I cannot seem to find a way to define/restrict a string
> length. This is probably by design and raises the topic in question.


That's a separate issue from being buffer overflow proof. You can't
specify that a string have a maximum of N characters except by slicing
the string after it's formed:

s = "x"*10000 # Make a big string.
s = s[:100] # Limit it to 100 characters.

But Python won't overflow any buffers even if you try to create a truly
huge string:

s = "x"*(1024**4) # Try to create a 1 TB string.

Your PC will run slow while Python and the OS tries to allocate 1TB of
memory, then it will safely raise MemoryError. Pure Python should never
dump core.



--
Steven


Steven D'Aprano
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Computer Security aldrich.chappel.com.use@gmail.com A+ Certification 0 11-27-2007 02:11 AM
Death Proof is a loser.... Jordan DVD Video 10 09-29-2007 12:31 AM
Re: YOU ALL NEED TO SEE THIS JAW DROPPING PROOF THAT THE U.S. ADMINISTRATION WAS 100 % BEHIND THE SEPT 11 ATTACKS RichA DVD Video 4 12-03-2005 03:10 PM
YOU ALL NEED TO SEE THIS JAW DROPPING PROOF THAT THE U.S. ADMINISTRATION WAS 100 % BEHIND THE SEPT 11 ATTACKS lharmen DVD Video 1 06-26-2005 07:33 AM
Newbie question - Buffer underruns and Nerovision Express telba most DVD Video 1 03-07-2005 11:14 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46