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
9e6b9750
Kaydet (Commit)
9e6b9750
authored
Agu 21, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17119: Fixed integer overflows when processing large strings and tuples
in the tkinter module.
üst
f77b4b20
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
10 deletions
+48
-10
test_tcl.py
Lib/test/test_tcl.py
+15
-1
NEWS
Misc/NEWS
+3
-0
_tkinter.c
Modules/_tkinter.c
+30
-9
No files found.
Lib/test/test_tcl.py
Dosyayı görüntüle @
9e6b9750
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
unittest
import
unittest
import
sys
import
sys
import
os
import
os
import
_testcapi
from
test
import
support
from
test
import
support
# Skip this test if the _tkinter module wasn't built.
# Skip this test if the _tkinter module wasn't built.
...
@@ -236,8 +237,21 @@ class TclTest(unittest.TestCase):
...
@@ -236,8 +237,21 @@ class TclTest(unittest.TestCase):
self
.
assertEqual
(
split
(
arg
),
res
,
msg
=
arg
)
self
.
assertEqual
(
split
(
arg
),
res
,
msg
=
arg
)
class
BigmemTclTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
interp
=
Tcl
()
@unittest.skipUnless
(
_testcapi
.
INT_MAX
<
_testcapi
.
PY_SSIZE_T_MAX
,
"needs UINT_MAX < SIZE_MAX"
)
@support.bigmemtest
(
size
=
_testcapi
.
INT_MAX
+
1
,
memuse
=
5
,
dry_run
=
False
)
def
test_huge_string
(
self
,
size
):
value
=
' '
*
size
self
.
assertRaises
(
OverflowError
,
self
.
interp
.
call
,
'set'
,
'_'
,
value
)
def
test_main
():
def
test_main
():
support
.
run_unittest
(
TclTest
,
TkinterTest
)
support
.
run_unittest
(
TclTest
,
TkinterTest
,
BigmemTclTest
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Misc/NEWS
Dosyayı görüntüle @
9e6b9750
...
@@ -66,6 +66,9 @@ Core and Builtins
...
@@ -66,6 +66,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #17119: Fixed integer overflows when processing large strings and tuples
in the tkinter module.
- Issue #18747: Re-seed OpenSSL'
s
pseudo
-
random
number
generator
after
fork
.
- Issue #18747: Re-seed OpenSSL'
s
pseudo
-
random
number
generator
after
fork
.
A
pthread_atfork
()
child
handler
is
used
to
seeded
the
PRNG
with
pid
,
time
A
pthread_atfork
()
child
handler
is
used
to
seeded
the
PRNG
with
pid
,
time
and
some
stack
data
.
and
some
stack
data
.
...
...
Modules/_tkinter.c
Dosyayı görüntüle @
9e6b9750
...
@@ -47,6 +47,9 @@ Copyright (C) 1994 Steen Lumholt.
...
@@ -47,6 +47,9 @@ Copyright (C) 1994 Steen Lumholt.
#define PyBool_FromLong PyLong_FromLong
#define PyBool_FromLong PyLong_FromLong
#endif
#endif
#define CHECK_SIZE(size, elemsize) \
((size_t)(size) <= Py_MAX((size_t)INT_MAX, UINT_MAX / (size_t)(elemsize)))
/* Starting with Tcl 8.4, many APIs offer const-correctness. Unfortunately,
/* Starting with Tcl 8.4, many APIs offer const-correctness. Unfortunately,
making _tkinter correct for this API means to break earlier
making _tkinter correct for this API means to break earlier
versions. USE_COMPAT_CONST allows to make _tkinter work with both 8.4 and
versions. USE_COMPAT_CONST allows to make _tkinter work with both 8.4 and
...
@@ -364,7 +367,7 @@ Merge(PyObject *args)
...
@@ -364,7 +367,7 @@ Merge(PyObject *args)
char
**
argv
=
NULL
;
char
**
argv
=
NULL
;
int
fvStore
[
ARGSZ
];
int
fvStore
[
ARGSZ
];
int
*
fv
=
NULL
;
int
*
fv
=
NULL
;
in
t
argc
=
0
,
fvc
=
0
,
i
;
Py_ssize_
t
argc
=
0
,
fvc
=
0
,
i
;
char
*
res
=
NULL
;
char
*
res
=
NULL
;
if
(
!
(
tmp
=
PyList_New
(
0
)))
if
(
!
(
tmp
=
PyList_New
(
0
)))
...
@@ -386,8 +389,12 @@ Merge(PyObject *args)
...
@@ -386,8 +389,12 @@ Merge(PyObject *args)
argc
=
PyTuple_Size
(
args
);
argc
=
PyTuple_Size
(
args
);
if
(
argc
>
ARGSZ
)
{
if
(
argc
>
ARGSZ
)
{
argv
=
(
char
**
)
ckalloc
(
argc
*
sizeof
(
char
*
));
if
(
!
CHECK_SIZE
(
argc
,
sizeof
(
char
*
)))
{
fv
=
(
int
*
)
ckalloc
(
argc
*
sizeof
(
int
));
PyErr_SetString
(
PyExc_OverflowError
,
"tuple is too long"
);
goto
finally
;
}
argv
=
(
char
**
)
ckalloc
((
size_t
)
argc
*
sizeof
(
char
*
));
fv
=
(
int
*
)
ckalloc
((
size_t
)
argc
*
sizeof
(
int
));
if
(
argv
==
NULL
||
fv
==
NULL
)
{
if
(
argv
==
NULL
||
fv
==
NULL
)
{
PyErr_NoMemory
();
PyErr_NoMemory
();
goto
finally
;
goto
finally
;
...
@@ -966,12 +973,18 @@ AsObj(PyObject *value)
...
@@ -966,12 +973,18 @@ AsObj(PyObject *value)
else
if
(
PyFloat_Check
(
value
))
else
if
(
PyFloat_Check
(
value
))
return
Tcl_NewDoubleObj
(
PyFloat_AS_DOUBLE
(
value
));
return
Tcl_NewDoubleObj
(
PyFloat_AS_DOUBLE
(
value
));
else
if
(
PyTuple_Check
(
value
))
{
else
if
(
PyTuple_Check
(
value
))
{
Tcl_Obj
**
argv
=
(
Tcl_Obj
**
)
Tcl_Obj
**
argv
;
ckalloc
(
PyTuple_Size
(
value
)
*
sizeof
(
Tcl_Obj
*
));
Py_ssize_t
size
,
i
;
int
i
;
size
=
PyTuple_Size
(
value
);
if
(
!
CHECK_SIZE
(
size
,
sizeof
(
Tcl_Obj
*
)))
{
PyErr_SetString
(
PyExc_OverflowError
,
"tuple is too long"
);
return
NULL
;
}
argv
=
(
Tcl_Obj
**
)
ckalloc
(((
size_t
)
size
)
*
sizeof
(
Tcl_Obj
*
));
if
(
!
argv
)
if
(
!
argv
)
return
0
;
return
0
;
for
(
i
=
0
;
i
<
PyTuple_Size
(
value
);
i
++
)
for
(
i
=
0
;
i
<
size
;
i
++
)
argv
[
i
]
=
AsObj
(
PyTuple_GetItem
(
value
,
i
));
argv
[
i
]
=
AsObj
(
PyTuple_GetItem
(
value
,
i
));
result
=
Tcl_NewListObj
(
PyTuple_Size
(
value
),
argv
);
result
=
Tcl_NewListObj
(
PyTuple_Size
(
value
),
argv
);
ckfree
(
FREECAST
argv
);
ckfree
(
FREECAST
argv
);
...
@@ -990,6 +1003,10 @@ AsObj(PyObject *value)
...
@@ -990,6 +1003,10 @@ AsObj(PyObject *value)
inbuf
=
PyUnicode_DATA
(
value
);
inbuf
=
PyUnicode_DATA
(
value
);
size
=
PyUnicode_GET_LENGTH
(
value
);
size
=
PyUnicode_GET_LENGTH
(
value
);
if
(
!
CHECK_SIZE
(
size
,
sizeof
(
Tcl_UniChar
)))
{
PyErr_SetString
(
PyExc_OverflowError
,
"string is too long"
);
return
NULL
;
}
kind
=
PyUnicode_KIND
(
value
);
kind
=
PyUnicode_KIND
(
value
);
allocsize
=
((
size_t
)
size
)
*
sizeof
(
Tcl_UniChar
);
allocsize
=
((
size_t
)
size
)
*
sizeof
(
Tcl_UniChar
);
outbuf
=
(
Tcl_UniChar
*
)
ckalloc
(
allocsize
);
outbuf
=
(
Tcl_UniChar
*
)
ckalloc
(
allocsize
);
...
@@ -1145,7 +1162,7 @@ static Tcl_Obj**
...
@@ -1145,7 +1162,7 @@ static Tcl_Obj**
Tkapp_CallArgs
(
PyObject
*
args
,
Tcl_Obj
**
objStore
,
int
*
pobjc
)
Tkapp_CallArgs
(
PyObject
*
args
,
Tcl_Obj
**
objStore
,
int
*
pobjc
)
{
{
Tcl_Obj
**
objv
=
objStore
;
Tcl_Obj
**
objv
=
objStore
;
in
t
objc
=
0
,
i
;
Py_ssize_
t
objc
=
0
,
i
;
if
(
args
==
NULL
)
if
(
args
==
NULL
)
/* do nothing */
;
/* do nothing */
;
...
@@ -1160,7 +1177,11 @@ Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc)
...
@@ -1160,7 +1177,11 @@ Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc)
objc
=
PyTuple_Size
(
args
);
objc
=
PyTuple_Size
(
args
);
if
(
objc
>
ARGSZ
)
{
if
(
objc
>
ARGSZ
)
{
objv
=
(
Tcl_Obj
**
)
ckalloc
(
objc
*
sizeof
(
char
*
));
if
(
!
CHECK_SIZE
(
objc
,
sizeof
(
Tcl_Obj
*
)))
{
PyErr_SetString
(
PyExc_OverflowError
,
"tuple is too long"
);
return
NULL
;
}
objv
=
(
Tcl_Obj
**
)
ckalloc
(((
size_t
)
objc
)
*
sizeof
(
Tcl_Obj
*
));
if
(
objv
==
NULL
)
{
if
(
objv
==
NULL
)
{
PyErr_NoMemory
();
PyErr_NoMemory
();
objc
=
0
;
objc
=
0
;
...
...
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