[New-bugs-announce] [issue23860] Failure to check return value from lseek() in Modules/mmapmodule.c

Bill Parker report at bugs.python.org
Fri Apr 3 19:44:00 CEST 2015


New submission from Bill Parker:

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...

----------
components: Interpreter Core
files: mmapmodule.c.patch
keywords: patch
messages: 240015
nosy: dogbert2
priority: normal
severity: normal
status: open
title: Failure to check return value from lseek() in Modules/mmapmodule.c
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file38823/mmapmodule.c.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23860>
_______________________________________


More information about the New-bugs-announce mailing list