Merge lp:~gz/brz/crc_asul into lp:brz

Proposed by Martin Packman on 2018-11-17
Status: Merged
Approved by: Martin Packman on 2018-11-17
Approved revision: 7184
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~gz/brz/crc_asul
Merge into: lp:brz
Diff against target: 30 lines (+3/-3)
1 file modified
breezy/bzr/_chk_map_pyx.pyx (+3/-3)
To merge this branch: bzr merge lp:~gz/brz/crc_asul
Reviewer Review Type Date Requested Status
Jelmer Vernooij 2018-11-17 Approve on 2018-11-17
Review via email: mp+358941@code.launchpad.net

Commit message

Possible fix for OverflowError in _search_key_255

Description of the change

Possible fix for OverflowError in _search_key_255

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908984

To post a comment you must log in.
Jelmer Vernooij (jelmer) wrote :

Thanks! Verified on armhf.

review: Approve
lp:~gz/brz/crc_asul updated on 2018-11-17
7184. By Martin Packman on 2018-11-17

Reintroduce mask for _search_key_16

Needed for Python 2 on 64-bit where zlib.crc32 returns a negative value.
Specifying the UL suffix at least generates plain C code without going
through a Python object and additional Cython conversion functions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/_chk_map_pyx.pyx'
2--- breezy/bzr/_chk_map_pyx.pyx 2018-07-12 01:43:49 +0000
3+++ breezy/bzr/_chk_map_pyx.pyx 2018-11-17 18:22:51 +0000
4@@ -41,7 +41,7 @@
5 PyDict_SetItem,
6 )
7 from cpython.int cimport (
8- PyInt_AS_LONG,
9+ PyInt_AsUnsignedLongMask,
10 )
11 from cpython.object cimport (
12 PyObject,
13@@ -102,7 +102,7 @@
14 if i > 0:
15 c_out[0] = c'\x00'
16 c_out = c_out + 1
17- crc_val = PyInt_AS_LONG(crc32(key[i])) & <unsigned long>0xFFFFFFFF
18+ crc_val = PyInt_AsUnsignedLongMask(crc32(key[i])) & 0xFFFFFFFFUL
19 # Hex(val) order
20 sprintf(c_out, '%08lX', crc_val)
21 c_out = c_out + 8
22@@ -127,7 +127,7 @@
23 if i > 0:
24 c_out[0] = c'\x00'
25 c_out = c_out + 1
26- crc_val = PyInt_AS_LONG(crc32(key[i]))
27+ crc_val = PyInt_AsUnsignedLongMask(crc32(key[i]))
28 # MSB order
29 c_out[0] = (crc_val >> 24) & 0xFF
30 c_out[1] = (crc_val >> 16) & 0xFF

Subscribers

People subscribed via source and target branches