Skip to content

Commit cbfb46e

Browse files
[Storage] Fix CRC64 extension with large data (Azure#39655)
1 parent 95ed0a7 commit cbfb46e

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

sdk/storage/azure-storage-extensions/azure/storage/extensions/crc64/crc64module.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PyObject* compute(PyObject* self, PyObject* args) {
1515
if (!PyArg_ParseTuple(args, "y#K", &src, &length, &uCrc))
1616
return NULL;
1717

18-
int pData = 0;
18+
uint64_t pData = 0;
1919
uint64_t uSize = (uint64_t)length;
2020
uint64_t uBytes, uStop;
2121

@@ -25,12 +25,12 @@ PyObject* compute(PyObject* self, PyObject* args) {
2525
uStop = uSize - (uSize % 32);
2626
if (uStop >= 2 * 32)
2727
{
28-
uint64_t uCrc0 = 0ULL;
29-
uint64_t uCrc1 = 0ULL;
30-
uint64_t uCrc2 = 0ULL;
31-
uint64_t uCrc3 = 0ULL;
28+
uint64_t uCrc0 = 0;
29+
uint64_t uCrc1 = 0;
30+
uint64_t uCrc2 = 0;
31+
uint64_t uCrc3 = 0;
3232

33-
int pLast = pData + (int)uStop - 32;
33+
uint64_t pLast = pData + uStop - 32;
3434
uSize -= uStop;
3535
uCrc0 = uCrc;
3636

sdk/storage/azure-storage-extensions/tests/test_crc64.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ def test_compute(data, initial, expected):
4949
actual = crc64.compute(data, initial)
5050
assert actual == expected
5151

52-
def test_compute_chunks():
53-
data = os.urandom(4 * 1024 * 1024)
52+
@pytest.mark.parametrize("size", [1024, 4 * 1024 * 1024, 1 * 1024 * 1024 * 1024, 3 * 1024 * 1024 * 1024])
53+
def test_compute_chunks(size):
54+
data = b''
55+
while len(data) < size:
56+
length = min(size - len(data), 1 * 1024 * 1024 * 1024)
57+
data += os.urandom(length)
58+
5459
chunk_size = 1024 * 1024
5560
full_crc = crc64.compute(data, 0)
5661

0 commit comments

Comments
 (0)