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
2ef7c478
Kaydet (Commit)
2ef7c478
authored
Nis 20, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23728: binascii.crc_hqx() could return an integer outside of the range
0-0xffff for empty data.
üst
16b2e4f5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
15 deletions
+30
-15
test_binascii.py
Lib/test/test_binascii.py
+12
-0
NEWS
Misc/NEWS
+3
-0
binascii.c
Modules/binascii.c
+8
-8
binascii.c.h
Modules/clinic/binascii.c.h
+7
-7
No files found.
Lib/test/test_binascii.py
Dosyayı görüntüle @
2ef7c478
...
...
@@ -136,6 +136,18 @@ class BinASCIITest(unittest.TestCase):
# Issue #7701 (crash on a pydebug build)
self
.
assertEqual
(
binascii
.
b2a_uu
(
b
'x'
),
b
'!>
\n
'
)
def
test_crc_hqx
(
self
):
crc
=
binascii
.
crc_hqx
(
self
.
type2test
(
b
"Test the CRC-32 of"
),
0
)
crc
=
binascii
.
crc_hqx
(
self
.
type2test
(
b
" this string."
),
crc
)
self
.
assertEqual
(
crc
,
14290
)
self
.
assertRaises
(
TypeError
,
binascii
.
crc_hqx
)
self
.
assertRaises
(
TypeError
,
binascii
.
crc_hqx
,
self
.
type2test
(
b
''
))
for
crc
in
0
,
1
,
0x1234
,
0x12345
,
0x12345678
,
-
1
:
self
.
assertEqual
(
binascii
.
crc_hqx
(
self
.
type2test
(
b
''
),
crc
),
crc
&
0xffff
)
def
test_crc32
(
self
):
crc
=
binascii
.
crc32
(
self
.
type2test
(
b
"Test the CRC-32 of"
))
crc
=
binascii
.
crc32
(
self
.
type2test
(
b
" this string."
),
crc
)
...
...
Misc/NEWS
Dosyayı görüntüle @
2ef7c478
...
...
@@ -29,6 +29,9 @@ Core and Builtins
Library
-------
- Issue #23728: binascii.crc_hqx() could return an integer outside of the range
0-0xffff for empty data.
- Issue #23811: Add missing newline to the PyCompileError error message.
Patch by Alex Shkop.
...
...
Modules/binascii.c
Dosyayı görüntüle @
2ef7c478
...
...
@@ -909,31 +909,31 @@ binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic input]
binascii.crc_hqx -> int
binascii.crc_hqx ->
unsigned_
int
data: Py_buffer
crc:
int
crc:
unsigned_int(bitwise=True)
/
Compute hqx CRC incrementally.
[clinic start generated code]*/
static
int
binascii_crc_hqx_impl
(
PyModuleDef
*
module
,
Py_buffer
*
data
,
int
crc
)
/*[clinic end generated code: output=
634dac18dfa863d7 input=68060931b2f51c8
a]*/
static
unsigned
int
binascii_crc_hqx_impl
(
PyModuleDef
*
module
,
Py_buffer
*
data
,
unsigned
int
crc
)
/*[clinic end generated code: output=
167c2dac62625717 input=add8c53712ccced
a]*/
{
unsigned
char
*
bin_data
;
unsigned
int
ucrc
=
(
unsigned
int
)
crc
;
Py_ssize_t
len
;
crc
&=
0xffff
;
bin_data
=
data
->
buf
;
len
=
data
->
len
;
while
(
len
--
>
0
)
{
ucrc
=
((
ucrc
<<
8
)
&
0xff00
)
^
crctab_hqx
[((
ucrc
>>
8
)
&
0xff
)
^*
bin_data
++
];
crc
=
((
crc
<<
8
)
&
0xff00
)
^
crctab_hqx
[(
crc
>>
8
)
^*
bin_data
++
];
}
return
(
int
)
u
crc
;
return
crc
;
}
#ifndef USE_ZLIB_CRC32
...
...
Modules/clinic/binascii.c.h
Dosyayı görüntüle @
2ef7c478
...
...
@@ -267,25 +267,25 @@ PyDoc_STRVAR(binascii_crc_hqx__doc__,
#define BINASCII_CRC_HQX_METHODDEF \
{"crc_hqx", (PyCFunction)binascii_crc_hqx, METH_VARARGS, binascii_crc_hqx__doc__},
static
int
binascii_crc_hqx_impl
(
PyModuleDef
*
module
,
Py_buffer
*
data
,
int
crc
);
static
unsigned
int
binascii_crc_hqx_impl
(
PyModuleDef
*
module
,
Py_buffer
*
data
,
unsigned
int
crc
);
static
PyObject
*
binascii_crc_hqx
(
PyModuleDef
*
module
,
PyObject
*
args
)
{
PyObject
*
return_value
=
NULL
;
Py_buffer
data
=
{
NULL
,
NULL
};
int
crc
;
int
_return_value
;
unsigned
int
crc
;
unsigned
int
_return_value
;
if
(
!
PyArg_ParseTuple
(
args
,
"y*
i
:crc_hqx"
,
"y*
I
:crc_hqx"
,
&
data
,
&
crc
))
goto
exit
;
_return_value
=
binascii_crc_hqx_impl
(
module
,
&
data
,
crc
);
if
((
_return_value
==
-
1
)
&&
PyErr_Occurred
())
goto
exit
;
return_value
=
PyLong_From
Long
((
long
)
_return_value
);
return_value
=
PyLong_From
UnsignedLong
((
unsigned
long
)
_return_value
);
exit:
/* Cleanup for data */
...
...
@@ -543,4 +543,4 @@ exit:
return
return_value
;
}
/*[clinic end generated code: output=
e46d29f8c9adae7e
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
22761b36f4f9e5bb
input=a9049054013a1b77]*/
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