Message289657
In Python 2.7.12 when reading, writing and subsequently reading again from a file, python seems to write garbage.
For example when running this in python IDLE:
import os
testPath = r"myTestFile.txt"
## Make sure the file exists and its empty
with open(testPath,"w") as tFile:
tFile.write("")
print "Our Test File: ", os.path.abspath(testPath )
with open(testPath, "r+") as tFile:
## First we read the file
data = tFile.read()
## Now we write some data
tFile.write('Some Data')
## Now we read the file again
tFile.read()
When now looking at the file the data is the following:
Some Data @ sb d Z d d l m Z d d d ・ ・ YZ e d k r^ d d l m Z e d d d d e ・n d S( s9
Implement Idle Shell history mechanism with History
...<omitted the rest of the data>
As mentioned in the comments on stack overflow ( see link ) this might be a buffer overrun but I am not sure. Also I guess this could be used as a security vulnerability...
http://stackoverflow.com/questions/40373457/python-r-read-write-read-writes-garbage-to-a-file?noredirect=1#comment72580538_40373457 |
|
Date |
User |
Action |
Args |
2017-03-15 09:47:30 | jan | set | recipients:
+ jan, paul.moore, tim.golden, zach.ware, steve.dower |
2017-03-15 09:47:30 | jan | set | messageid: <1489571250.73.0.412338383823.issue29817@psf.upfronthosting.co.za> |
2017-03-15 09:47:30 | jan | link | issue29817 messages |
2017-03-15 09:47:30 | jan | create | |
|