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
c6dd4152
Kaydet (Commit)
c6dd4152
authored
Eki 27, 2016
tarafından
Steve Dower
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28522: Fixes mishandled buffer reallocation in getpathp.c
üst
e45ef4e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
4 deletions
+72
-4
test_site.py
Lib/test/test_site.py
+52
-0
NEWS
Misc/NEWS
+5
-0
getpathp.c
PC/getpathp.c
+15
-4
No files found.
Lib/test/test_site.py
Dosyayı görüntüle @
c6dd4152
...
...
@@ -488,6 +488,58 @@ class StartupImportTests(unittest.TestCase):
'import site, sys; site.enablerlcompleter(); sys.exit(hasattr(sys, "__interactivehook__"))'
])
.
wait
()
self
.
assertTrue
(
r
,
"'__interactivehook__' not added by enablerlcompleter()"
)
@unittest.skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
def
test_underpth_nosite_file
(
self
):
_pth_file
=
os
.
path
.
splitext
(
sys
.
executable
)[
0
]
+
'._pth'
try
:
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
with
open
(
_pth_file
,
'w'
)
as
f
:
print
(
'fake-path-name'
,
file
=
f
)
# Ensure the generated path is very long so that buffer
# resizing in getpathp.c is exercised
for
_
in
range
(
200
):
print
(
libpath
,
file
=
f
)
print
(
'# comment'
,
file
=
f
)
env
=
os
.
environ
.
copy
()
env
[
'PYTHONPATH'
]
=
'from-env'
rc
=
subprocess
.
call
([
sys
.
executable
,
'-c'
,
'import sys; sys.exit(sys.flags.no_site and '
'len(sys.path) > 200 and '
'
%
r in sys.path and
%
r in sys.path and
%
r not in sys.path)'
%
(
os
.
path
.
join
(
sys
.
prefix
,
'fake-path-name'
),
libpath
,
os
.
path
.
join
(
sys
.
prefix
,
'from-env'
),
)],
env
=
env
)
self
.
assertEqual
(
rc
,
0
)
finally
:
os
.
unlink
(
_pth_file
)
@unittest.skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
def
test_underpth_file
(
self
):
_pth_file
=
os
.
path
.
splitext
(
sys
.
executable
)[
0
]
+
'._pth'
try
:
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
with
open
(
_pth_file
,
'w'
)
as
f
:
print
(
'fake-path-name'
,
file
=
f
)
for
_
in
range
(
200
):
print
(
libpath
,
file
=
f
)
print
(
'# comment'
,
file
=
f
)
print
(
'import site'
,
file
=
f
)
env
=
os
.
environ
.
copy
()
env
[
'PYTHONPATH'
]
=
'from-env'
rc
=
subprocess
.
call
([
sys
.
executable
,
'-c'
,
'import sys; sys.exit(not sys.flags.no_site and '
'
%
r in sys.path and
%
r in sys.path and
%
r not in sys.path)'
%
(
os
.
path
.
join
(
sys
.
prefix
,
'fake-path-name'
),
libpath
,
os
.
path
.
join
(
sys
.
prefix
,
'from-env'
),
)],
env
=
env
)
self
.
assertEqual
(
rc
,
0
)
finally
:
os
.
unlink
(
_pth_file
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
c6dd4152
...
...
@@ -85,6 +85,11 @@ Library
threadpool executor.
Initial patch by Hans Lawrenz.
Windows
-------
- Issue #28522: Fixes mishandled buffer reallocation in getpathp.c
Build
-----
...
...
PC/getpathp.c
Dosyayı görüntüle @
c6dd4152
...
...
@@ -581,7 +581,8 @@ read_pth_file(const wchar_t *path, wchar_t *prefix, int *isolated, int *nosite)
wn
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
line
,
-
1
,
wline
,
wn
+
1
);
wline
[
wn
]
=
'\0'
;
while
(
wn
+
prefixlen
+
4
>
bufsiz
)
{
size_t
usedsiz
=
wcslen
(
buf
);
while
(
usedsiz
+
wn
+
prefixlen
+
4
>
bufsiz
)
{
bufsiz
+=
MAXPATHLEN
;
buf
=
(
wchar_t
*
)
PyMem_RawRealloc
(
buf
,
(
bufsiz
+
1
)
*
sizeof
(
wchar_t
));
if
(
!
buf
)
{
...
...
@@ -590,11 +591,21 @@ read_pth_file(const wchar_t *path, wchar_t *prefix, int *isolated, int *nosite)
}
}
if
(
buf
[
0
])
if
(
usedsiz
)
{
wcscat_s
(
buf
,
bufsiz
,
L";"
);
usedsiz
+=
1
;
}
wchar_t
*
b
=
&
buf
[
wcslen
(
buf
)];
wcscat_s
(
buf
,
bufsiz
,
prefix
);
errno_t
result
;
_Py_BEGIN_SUPPRESS_IPH
result
=
wcscat_s
(
buf
,
bufsiz
,
prefix
);
_Py_END_SUPPRESS_IPH
if
(
result
==
EINVAL
)
{
Py_FatalError
(
"invalid argument during ._pth processing"
);
}
else
if
(
result
==
ERANGE
)
{
Py_FatalError
(
"buffer overflow during ._pth processing"
);
}
wchar_t
*
b
=
&
buf
[
usedsiz
];
join
(
b
,
wline
);
PyMem_RawFree
(
wline
);
...
...
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