Issue 23860: Windows: Failure to check return value from lseek() in Modules/mmapmodule.c (original) (raw)

Created on 2015-04-03 17:44 by dogbert2, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
mmapmodule.c.patch dogbert2,2015-04-03 17:43 patch file (diff -u) for this bug
Pull Requests
URL Status Linked Edit
PR 7017 open ZackerySpytz,2018-05-20 17:44
Messages (7)
msg240015 - (view) Author: Bill Parker (dogbert2) * Date: 2015-04-03 17:43
Hello All, In reviewing code in directory Python-3.4.3/Modules, file 'mmapmodule', I found a call to 'lseek()' without a check for a return value of -1, indicating failure. The patch file below corrects this issue (diff -u format): --- mmapmodule.c.orig 2015-04-02 19:05:30.380554538 -0700 +++ mmapmodule.c 2015-04-02 19:11:00.320488207 -0700 @@ -1335,7 +1335,11 @@ return NULL; } /* Win9x appears to need us seeked to zero */ - lseek(fileno, 0, SEEK_SET); + if (lseek(fileno, 0, SEEK_SET) == -1) { /* call to lseek() failed */ + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + } m_obj = (mmap_object *)type->tp_alloc(type, 0); I am attaching the patch file to this bug report...
msg240051 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-04-04 08:32
Thanks for the patch, Bill. If you want to work on similar issues see also issue 15948.
msg240088 - (view) Author: Bill Parker (dogbert2) * Date: 2015-04-04 20:07
I would check 23855 as well, since the malloc() missing a sanity check, which could be a more serious issue .. On Sat, Apr 4, 2015 at 1:32 AM, Berker Peksag <report@bugs.python.org> wrote: > > Berker Peksag added the comment: > > Thanks for the patch, Bill. If you want to work on similar issues see also > issue 15948. > > ---------- > components: +Extension Modules -Interpreter Core > nosy: +berker.peksag, haypo, serhiy.storchaka > stage: -> patch review > versions: +Python 3.5 > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue23860> > _______________________________________ >
msg240383 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-04-09 20:35
> /* Win9x appears to need us seeked to zero */ > lseek(fileno, 0, SEEK_SET); Hum, is it still needed in 2015 with Python 3.5? We even dropped support for Windows XP.
msg240384 - (view) Author: Bill Parker (dogbert2) * Date: 2015-04-09 20:37
At the moment, I'm not sure if it's needed or not, but if it's only an issue with XP, then it might not be worth fixing...:) On Thu, Apr 9, 2015 at 1:35 PM, STINNER Victor <report@bugs.python.org> wrote: > > STINNER Victor added the comment: > > > /* Win9x appears to need us seeked to zero */ > > lseek(fileno, 0, SEEK_SET); > > Hum, is it still needed in 2015 with Python 3.5? We even dropped support > for Windows XP. > > ---------- > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue23860> > _______________________________________ >
msg317284 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-22 13:45
"At the moment, I'm not sure if it's needed or not, but if it's only an issue with XP, then it might not be worth fixing...:)" If the workaround is no longer needed, the lseek() call should be removed.
msg317285 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-22 13:47
Oh right, PR 7017 does that: it removes the lseek() call ;-)
History
Date User Action Args
2022-04-11 14:58:15 admin set github: 68048
2020-07-15 17:06:15 serhiy.storchaka set versions: + Python 3.10, - Python 3.8
2018-05-22 13:47:29 vstinner set messages: +
2018-05-22 13:45:10 vstinner set title: Failure to check return value from lseek() in Modules/mmapmodule.c -> Windows: Failure to check return value from lseek() in Modules/mmapmodule.cnosy: + paul.moore, tim.golden, zach.ware, steve.dowermessages: + components: + Windows
2018-05-20 17:46:13 ZackerySpytz set nosy: + ZackerySpytzversions: + Python 3.8, - Python 3.4, Python 3.5
2018-05-20 17:44:25 ZackerySpytz set pull_requests: + <pull%5Frequest6668>
2015-04-09 20:37:57 dogbert2 set messages: +
2015-04-09 20:35:39 vstinner set messages: +
2015-04-04 20:07:30 dogbert2 set messages: +
2015-04-04 08:32:47 berker.peksag link issue15948 dependencies
2015-04-04 08:32:26 berker.peksag set versions: + Python 3.5nosy: + berker.peksag, vstinner, serhiy.storchakamessages: + components: + Extension Modules, - Interpreter Corestage: patch review
2015-04-03 17:44:00 dogbert2 create