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
fd08fdc7
Kaydet (Commit)
fd08fdc7
authored
Kas 20, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25659: Change assert to TypeError in from_buffer/_copy()
Based on suggestion by Eryk Sun.
üst
f75a2ebb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
test_frombuffer.py
Lib/ctypes/test/test_frombuffer.py
+8
-0
NEWS
Misc/NEWS
+3
-0
_ctypes.c
Modules/_ctypes/_ctypes.c
+10
-4
No files found.
Lib/ctypes/test/test_frombuffer.py
Dosyayı görüntüle @
fd08fdc7
...
...
@@ -77,5 +77,13 @@ class Test(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
(
c_int
*
1
)
.
from_buffer_copy
,
a
,
16
*
sizeof
(
c_int
))
def
test_abstract
(
self
):
self
.
assertRaises
(
TypeError
,
Array
.
from_buffer
,
bytearray
(
10
))
self
.
assertRaises
(
TypeError
,
Structure
.
from_buffer
,
bytearray
(
10
))
self
.
assertRaises
(
TypeError
,
Union
.
from_buffer
,
bytearray
(
10
))
self
.
assertRaises
(
TypeError
,
Array
.
from_buffer_copy
,
b
"123"
)
self
.
assertRaises
(
TypeError
,
Structure
.
from_buffer_copy
,
b
"123"
)
self
.
assertRaises
(
TypeError
,
Union
.
from_buffer_copy
,
b
"123"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
fd08fdc7
...
...
@@ -63,6 +63,9 @@ Core and Builtins
Library
-------
- Issue #25659: In ctypes, prevent a crash calling the from_buffer() and
from_buffer_copy() methods on abstract classes like Array.
- Issue #28563: Fixed possible DoS and arbitrary code execution when handle
plural form selections in the gettext module. The expression parser now
supports exact syntax supported by GNU gettext.
...
...
Modules/_ctypes/_ctypes.c
Dosyayı görüntüle @
fd08fdc7
...
...
@@ -501,7 +501,10 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
Py_ssize_t
offset
=
0
;
PyObject
*
obj
,
*
result
;
StgDictObject
*
dict
=
PyType_stgdict
(
type
);
assert
(
dict
);
if
(
!
dict
)
{
PyErr_SetString
(
PyExc_TypeError
,
"abstract class"
);
return
NULL
;
}
if
(
!
PyArg_ParseTuple
(
args
,
#if (PY_VERSION_HEX < 0x02050000)
...
...
@@ -557,13 +560,16 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
Py_ssize_t
offset
=
0
;
PyObject
*
obj
,
*
result
;
StgDictObject
*
dict
=
PyType_stgdict
(
type
);
assert
(
dict
);
if
(
!
dict
)
{
PyErr_SetString
(
PyExc_TypeError
,
"abstract class"
);
return
NULL
;
}
if
(
!
PyArg_ParseTuple
(
args
,
#if (PY_VERSION_HEX < 0x02050000)
"O|i:from_buffer"
,
"O|i:from_buffer
_copy
"
,
#else
"O|n:from_buffer"
,
"O|n:from_buffer
_copy
"
,
#endif
&
obj
,
&
offset
))
return
NULL
;
...
...
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