Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ea47eaa3
Kaydet (Commit)
ea47eaa3
authored
Agu 01, 2010
tarafından
Brian Curtin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix #8105. Add validation to mmap.mmap so invalid file descriptors
don't cause a crash on Windows.
üst
0bccc185
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
test_mmap.py
Lib/test/test_mmap.py
+12
-1
NEWS
Misc/NEWS
+2
-0
mmapmodule.c
Modules/mmapmodule.c
+5
-0
No files found.
Lib/test/test_mmap.py
Dosyayı görüntüle @
ea47eaa3
from
test.support
import
TESTFN
,
run_unittest
,
import_module
from
test.support
import
TESTFN
,
run_unittest
,
import_module
import
unittest
import
unittest
import
os
,
re
,
itertools
import
os
,
re
,
itertools
,
socket
# Skip test if we can't import mmap.
# Skip test if we can't import mmap.
mmap
=
import_module
(
'mmap'
)
mmap
=
import_module
(
'mmap'
)
...
@@ -586,6 +586,17 @@ class MmapTests(unittest.TestCase):
...
@@ -586,6 +586,17 @@ class MmapTests(unittest.TestCase):
pass
pass
m
.
close
()
m
.
close
()
def
test_invalid_descriptor
(
self
):
# socket file descriptors are valid, but out of range
# for _get_osfhandle, causing a crash when validating the
# parameters to _get_osfhandle.
s
=
socket
.
socket
()
try
:
with
self
.
assertRaises
(
mmap
.
error
):
m
=
mmap
.
mmap
(
s
.
fileno
(),
10
)
finally
:
s
.
close
()
def
test_context_manager
(
self
):
def
test_context_manager
(
self
):
with
mmap
.
mmap
(
-
1
,
10
)
as
m
:
with
mmap
.
mmap
(
-
1
,
10
)
as
m
:
self
.
assertFalse
(
m
.
closed
)
self
.
assertFalse
(
m
.
closed
)
...
...
Misc/NEWS
Dosyayı görüntüle @
ea47eaa3
...
@@ -21,6 +21,8 @@ Core and Builtins
...
@@ -21,6 +21,8 @@ Core and Builtins
Extensions
Extensions
----------
----------
- Issue #8105: Validate file descriptor passed to mmap.mmap on Windows.
- Issue #8046: Add context manager protocol support and .closed property
- Issue #8046: Add context manager protocol support and .closed property
to mmap objects.
to mmap objects.
...
...
Modules/mmapmodule.c
Dosyayı görüntüle @
ea47eaa3
...
@@ -1236,6 +1236,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
...
@@ -1236,6 +1236,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
1);
1);
*/
*/
if
(
fileno
!=
-
1
&&
fileno
!=
0
)
{
if
(
fileno
!=
-
1
&&
fileno
!=
0
)
{
/* Ensure that fileno is within the CRT's valid range */
if
(
_PyVerify_fd
(
fileno
)
==
0
)
{
PyErr_SetFromErrno
(
mmap_module_error
);
return
NULL
;
}
fh
=
(
HANDLE
)
_get_osfhandle
(
fileno
);
fh
=
(
HANDLE
)
_get_osfhandle
(
fileno
);
if
(
fh
==
(
HANDLE
)
-
1
)
{
if
(
fh
==
(
HANDLE
)
-
1
)
{
PyErr_SetFromErrno
(
mmap_module_error
);
PyErr_SetFromErrno
(
mmap_module_error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment