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
40fa2660
Kaydet (Commit)
40fa2660
authored
Ara 17, 2016
tarafından
Steve Dower
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25778: winreg does not truncase string correctly (Patch by Eryk Sun)
üst
ce042af3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
test_winreg.py
Lib/test/test_winreg.py
+13
-1
NEWS
Misc/NEWS
+2
-0
winreg.c
PC/winreg.c
+6
-7
No files found.
Lib/test/test_winreg.py
Dosyayı görüntüle @
40fa2660
...
@@ -57,7 +57,7 @@ class BaseWinregTests(unittest.TestCase):
...
@@ -57,7 +57,7 @@ class BaseWinregTests(unittest.TestCase):
def
delete_tree
(
self
,
root
,
subkey
):
def
delete_tree
(
self
,
root
,
subkey
):
try
:
try
:
hkey
=
OpenKey
(
root
,
subkey
,
KEY_ALL_ACCESS
)
hkey
=
OpenKey
(
root
,
subkey
,
0
,
KEY_ALL_ACCESS
)
except
OSError
:
except
OSError
:
# subkey does not exist
# subkey does not exist
return
return
...
@@ -368,6 +368,18 @@ class LocalWinregTests(BaseWinregTests):
...
@@ -368,6 +368,18 @@ class LocalWinregTests(BaseWinregTests):
finally
:
finally
:
DeleteKey
(
HKEY_CURRENT_USER
,
test_key_name
)
DeleteKey
(
HKEY_CURRENT_USER
,
test_key_name
)
def
test_read_string_containing_null
(
self
):
# Test for issue 25778: REG_SZ should not contain null characters
try
:
with
CreateKey
(
HKEY_CURRENT_USER
,
test_key_name
)
as
ck
:
self
.
assertNotEqual
(
ck
.
handle
,
0
)
test_val
=
"A string
\x00
with a null"
SetValueEx
(
ck
,
"test_name"
,
0
,
REG_SZ
,
test_val
)
ret_val
,
ret_type
=
QueryValueEx
(
ck
,
"test_name"
)
self
.
assertEqual
(
ret_type
,
REG_SZ
)
self
.
assertEqual
(
ret_val
,
"A string"
)
finally
:
DeleteKey
(
HKEY_CURRENT_USER
,
test_key_name
)
@unittest.skipUnless
(
REMOTE_NAME
,
"Skipping remote registry tests"
)
@unittest.skipUnless
(
REMOTE_NAME
,
"Skipping remote registry tests"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
40fa2660
...
@@ -49,6 +49,8 @@ Library
...
@@ -49,6 +49,8 @@ Library
Windows
Windows
-------
-------
- Issue #25778: winreg does not truncase string correctly (Patch by Eryk Sun)
- Issue #28896: Deprecate WindowsRegistryFinder and disable it by default.
- Issue #28896: Deprecate WindowsRegistryFinder and disable it by default.
Tests
Tests
...
...
PC/winreg.c
Dosyayı görüntüle @
40fa2660
...
@@ -719,14 +719,13 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
...
@@ -719,14 +719,13 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
case
REG_SZ
:
case
REG_SZ
:
case
REG_EXPAND_SZ
:
case
REG_EXPAND_SZ
:
{
{
/* the buffer may or may not have a trailing NULL */
/* REG_SZ should be a NUL terminated string, but only by
* convention. The buffer may have been saved without a NUL
* or with embedded NULs. To be consistent with reg.exe and
* regedit.exe, consume only up to the first NUL. */
wchar_t
*
data
=
(
wchar_t
*
)
retDataBuf
;
wchar_t
*
data
=
(
wchar_t
*
)
retDataBuf
;
int
len
=
retDataSize
/
2
;
size_t
len
=
wcsnlen
(
data
,
retDataSize
/
sizeof
(
wchar_t
));
if
(
retDataSize
&&
data
[
len
-
1
]
==
'\0'
)
obData
=
PyUnicode_FromWideChar
(
data
,
len
);
retDataSize
-=
2
;
if
(
retDataSize
<=
0
)
data
=
L""
;
obData
=
PyUnicode_FromWideChar
(
data
,
retDataSize
/
2
);
break
;
break
;
}
}
case
REG_MULTI_SZ
:
case
REG_MULTI_SZ
:
...
...
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