Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3a5e0a9

Browse files
committed
Fix the new ARMv8 CRC code for short and unaligned input.
The code before the main loop, to handle the possible 1-7 unaligned bytes at the beginning of the input, was broken, and read past the input, if the the input was very short.
1 parent ee9e145 commit 3a5e0a9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/port/pg_crc32c_armv8.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t len)
2929
* significantly faster. Process leading bytes so that the loop below
3030
* starts with a pointer aligned to eight bytes.
3131
*/
32-
if (!PointerIsAligned(p, uint16) && p < pend)
32+
if (!PointerIsAligned(p, uint16) && p + 1 <= pend)
3333
{
3434
crc = __crc32cb(crc, *p);
3535
p += 1;
3636
}
37-
if (!PointerIsAligned(p, uint32) && p < pend)
37+
if (!PointerIsAligned(p, uint32) && p + 2 <= pend)
3838
{
3939
crc = __crc32ch(crc, *(uint16 *) p);
4040
p += 2;
4141
}
42-
if (!PointerIsAligned(p, uint64) && p < pend)
42+
if (!PointerIsAligned(p, uint64) && p + 4 <= pend)
4343
{
4444
crc = __crc32cw(crc, *(uint32 *) p);
4545
p += 4;

0 commit comments

Comments
 (0)