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
1b3f3b03
Kaydet (Commit)
1b3f3b03
authored
Eyl 09, 2012
tarafından
Jesus Cea
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Closes #15676: mmap: add empty file check prior to offset check
üst
b21d48da
941bfcc5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
test_mmap.py
Lib/test/test_mmap.py
+9
-0
NEWS
Misc/NEWS
+3
-0
mmapmodule.c
Modules/mmapmodule.c
+5
-0
No files found.
Lib/test/test_mmap.py
Dosyayı görüntüle @
1b3f3b03
...
@@ -488,6 +488,15 @@ class MmapTests(unittest.TestCase):
...
@@ -488,6 +488,15 @@ class MmapTests(unittest.TestCase):
f
.
flush
()
f
.
flush
()
return
mmap
.
mmap
(
f
.
fileno
(),
0
)
return
mmap
.
mmap
(
f
.
fileno
(),
0
)
def
test_empty_file
(
self
):
f
=
open
(
TESTFN
,
'w+b'
)
f
.
close
()
f
=
open
(
TESTFN
,
"rb"
)
self
.
assertRaisesRegex
(
ValueError
,
"cannot mmap an empty file"
,
mmap
.
mmap
,
f
.
fileno
(),
0
,
access
=
mmap
.
ACCESS_READ
)
f
.
close
()
def
test_offset
(
self
):
def
test_offset
(
self
):
f
=
open
(
TESTFN
,
'w+b'
)
f
=
open
(
TESTFN
,
'w+b'
)
...
...
Misc/NEWS
Dosyayı görüntüle @
1b3f3b03
...
@@ -544,6 +544,9 @@ C API
...
@@ -544,6 +544,9 @@ C API
Extension Modules
Extension Modules
-----------------
-----------------
- Issue #15676: Now "mmap" check for empty files before doing the
offset check. Patch by Steven Willis.
- Issue #6493: An issue in ctypes on Windows that caused structure bitfields
- Issue #6493: An issue in ctypes on Windows that caused structure bitfields
of type ctypes.c_uint32 and width 32 to incorrectly be set has been fixed.
of type ctypes.c_uint32 and width 32 to incorrectly be set has been fixed.
...
...
Modules/mmapmodule.c
Dosyayı görüntüle @
1b3f3b03
...
@@ -1163,6 +1163,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
...
@@ -1163,6 +1163,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
if
(
fd
!=
-
1
&&
fstat
(
fd
,
&
st
)
==
0
&&
S_ISREG
(
st
.
st_mode
))
{
if
(
fd
!=
-
1
&&
fstat
(
fd
,
&
st
)
==
0
&&
S_ISREG
(
st
.
st_mode
))
{
if
(
map_size
==
0
)
{
if
(
map_size
==
0
)
{
off_t
calc_size
;
off_t
calc_size
;
if
(
st
.
st_size
==
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"cannot mmap an empty file"
);
return
NULL
;
}
if
(
offset
>=
st
.
st_size
)
{
if
(
offset
>=
st
.
st_size
)
{
PyErr_SetString
(
PyExc_ValueError
,
PyErr_SetString
(
PyExc_ValueError
,
"mmap offset is greater than file size"
);
"mmap offset is greater than file size"
);
...
...
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