homepage

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: Windows: Failure to check return value from lseek() in Modules/mmapmodule.c
Type: behavior Stage: patch review
Components: Extension Modules, Windows Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, berker.peksag, dogbert2, paul.moore, serhiy.storchaka, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords: patch

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:15adminsetgithub: 68048
2020年07月15日 17:06:15serhiy.storchakasetversions: + Python 3.10, - Python 3.8
2018年05月22日 13:47:29vstinnersetmessages: + msg317285
2018年05月22日 13:45:10vstinnersettitle: Failure to check return value from lseek() in Modules/mmapmodule.c -> Windows: Failure to check return value from lseek() in Modules/mmapmodule.c
nosy: + paul.moore, tim.golden, zach.ware, steve.dower

messages: + msg317284

components: + Windows
2018年05月20日 17:46:13ZackerySpytzsetnosy: + ZackerySpytz

versions: + Python 3.8, - Python 3.4, Python 3.5
2018年05月20日 17:44:25ZackerySpytzsetpull_requests: + pull_request6668
2015年04月09日 20:37:57dogbert2setmessages: + msg240384
2015年04月09日 20:35:39vstinnersetmessages: + msg240383
2015年04月04日 20:07:30dogbert2setmessages: + msg240088
2015年04月04日 08:32:47berker.peksaglinkissue15948 dependencies
2015年04月04日 08:32:26berker.peksagsetversions: + Python 3.5
nosy: + berker.peksag, vstinner, serhiy.storchaka

messages: + msg240051

components: + Extension Modules, - Interpreter Core
stage: patch review
2015年04月03日 17:44:00dogbert2create

AltStyle によって変換されたページ (->オリジナル) /