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.

Title: _PyImport_GetDynLoadFunc() doesn't check return value of fstat()
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, eric.snow, jcea, vstinner
Priority: normal Keywords:

Created on 2012-09-09 21:56 by christian.heimes, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg170138 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-09-09 21:56
The function _PyImport_GetDynLoadFunc() in Python/dynload_shlib.c doesn't check the return value of fstat()

CID 486250: Other violation (CHECKED_RETURN)At (3): Calling function "fstat(fileno(fp), &statb)" without checking return value. This library function may fail and return an error code.
At (4): No check of the return value of "fstat(fileno(fp), &statb)".
 93        fstat(fileno(fp), &statb);

Suggested fix:
if (fstat(fileno(fp), &statb) == -1) {
    PyErr_SetFromErrnoWithFilename(PyExc_IOError, pathname);
    return NULL;
msg193745 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-26 20:47
Already fixed
msg193747 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-07-26 20:49
changeset:   84741:654268ff29b5
branch:      3.3
parent:      84736:ce771c2d0220
user:        Christian Heimes <>
date:        Sat Jul 20 22:17:55 2013 +0200
files:       Python/dynload_shlib.c
Check return value of fstat() in  _PyImport_GetDynLoadFunc()
CID 486250
msg193749 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-26 20:51
I wonder why I did not mention the issue # in the checkin message... Thanks :)
Date User Action Args
2022-04-11 14:57:35adminsetgithub: 60096
2013-07-26 20:51:00christian.heimessetmessages: + msg193749
2013-07-26 20:49:09vstinnersetnosy: + vstinner
messages: + msg193747
2013-07-26 20:47:56christian.heimessetstatus: open -> closed
resolution: out of date
messages: + msg193745

stage: patch review -> resolved
2012-11-13 06:02:22eric.snowsetnosy: + eric.snow
2012-09-10 02:26:19jceasetnosy: + jcea
2012-09-09 21:56:02christian.heimescreate