![]() |
|
|
|||||||
![]() |
Python - Re: Is python buffer overflow proof? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |