[issue10451] memoryview can be used to write into readonly buffer
Changes by STINNER Victor victor.stin...@haypocalc.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Ross Lagerwall rosslagerw...@gmail.com added the comment: From what I can see, this issue is in memoryview and allows memoryview to export a readonly buffer as writable (because memoryview.getbuffer() removes the writable flag from flags before calling the underlying buffer). This causes segfaults when using mmap. If a bytes object is used as the underlying buffer, it allows the bytes object to be changed. Given this code: import io b=b m=memoryview(b) i=io.BytesIO(b'') i.readinto(m) print(b) print(b == b) The output is: b'' True I think this is due to interning. Anyway, attached is a patch which hopefully fixes the issue + a test. -- keywords: +patch nosy: +rosslagerwall Added file: http://bugs.python.org/file20437/i10451.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Antoine Pitrou pit...@free.fr added the comment: The patch produces a failure in test_getargs2, but that test is wrong and should be fixed: == ERROR: test_w_star (test.test_getargs2.Bytes_TestCase) -- Traceback (most recent call last): File /home/antoine/py3k/__svn__/Lib/test/test_getargs2.py, line 385, in test_w_star self.assertEqual(getargs_w_star(memoryview(b'memoryview')), b'[emoryvie]') TypeError: must be read-write buffer, not memoryview I'm surprised no other test failures arise. I did add that line (which I commented with XXX for whatever reason...) for a reason, but I don't remember which one. It seemed necessary at the time, I'm glad it isn't anymore. So, about the patch itself: you should simply use assertRaises. There's no reason for readinto() not to fail with a TypeError (silent failure is wrong). Thank you. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +georg.brandl priority: normal - critical ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Ross Lagerwall rosslagerw...@gmail.com added the comment: Attached is an updated patch with a simpler test. -- Added file: http://bugs.python.org/file20440/i10451_v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Ross Lagerwall rosslagerw...@gmail.com added the comment: And a simple fix for the test_getargs2 test - it wraps the memoryview around a bytearray. -- Added file: http://bugs.python.org/file20441/testfix.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Georg Brandl ge...@python.org added the comment: So, does critical mean should be release blocker? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Antoine Pitrou pit...@free.fr added the comment: So, does critical mean should be release blocker? It's up to you to decide. It's not a new bug AFAICT. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Georg Brandl ge...@python.org added the comment: The patch looks trivial enough. You're the memoryview guru, so if you have no doubts about it, I would say it can go in. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Antoine Pitrou pit...@free.fr added the comment: Patch with modified tests committed in r88097 (3.2), r88098 (3.1) and r88099 (2.7). Thank you! -- resolution: - fixed stage: - committed/rejected status: open - closed versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
Changes by Éric Araujo mer...@netwok.org: -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10451] memoryview can be used to write into readonly buffer
New submission from Evgeny Kapun abacabadabac...@gmail.com: This code crashes Python: import io, mmap io.BytesIO(b' ').readinto(memoryview(mmap.mmap(-1, 1, prot=mmap.PROT_READ))) -- components: Interpreter Core messages: 121446 nosy: abacabadabacaba priority: normal severity: normal status: open title: memoryview can be used to write into readonly buffer type: crash versions: Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com