This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: file readline w+ memory dumps
Type: security Stage:
Components: None Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, tempname1234
Priority: normal Keywords:

Created on 2008-05-01 10:35 by tempname1234, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg66032 - (view) Author: tempname (tempname1234) Date: 2008-05-01 10:34
the following code actually dumps the heap into the temp file... very
strange. Make sure the file doesn't exist before running the script.
Only the list of numbers should be written to the file, but alot of junk
is added.

x = str(range(10))
f = open('c:\\temp.txt', 'w+')
f.write(x)
for i in range(10):
    y = f.readline()
    print repr(y)

f.close()
msg66040 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-05-01 20:33
This is a duplicate of issue1394612, which was closed as "invalid". See
the discussion there:

- "in standard C mixing reads with writes yields undefined behavior [...]
If you want defined behavior, then, for example, add
>>> f.seek(0)
between your write() and read() calls."""

BTW, python 3.0 has a new implementation of the I/O stack, which does
not use fopen, and does not have this problem.
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46982
2008-05-01 20:33:08amaury.forgeotdarcsetstatus: open -> closed
resolution: wont fix
messages: + msg66040
nosy: + amaury.forgeotdarc
2008-05-01 10:35:01tempname1234create