Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27c4c3e

Browse files
committed
Check return value of fstat() in _PyImport_GetDynLoadFunc()
CID 486250
1 parent 58ceecf commit 27c4c3e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Python/dynload_shlib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
9090
if (fp != NULL) {
9191
int i;
9292
struct stat statb;
93-
fstat(fileno(fp), &statb);
93+
if (fstat(fileno(fp), &statb) == -1) {
94+
return PyErr_SetFromErrno(PyExc_IOError);
95+
}
9496
for (i = 0; i < nhandles; i++) {
9597
if (statb.st_dev == handles[i].dev &&
9698
statb.st_ino == handles[i].ino) {

0 commit comments

Comments
 (0)