]> git.ipfire.org Git - thirdparty/zlib-ng.git/commit
riscv: chunkset_rvv: fix SIGSEGV in CHUNKCOPY
authorIcenowy Zheng <uwu@icenowy.me>
Mon, 24 Mar 2025 08:50:37 +0000 (16:50 +0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 28 Mar 2025 14:30:21 +0000 (15:30 +0100)
commit2bba7e8468e808b7a7d5c1045d339eb5ffd12591
treea14dbed78f5cfc178cbcc26dabf390a3342c765f
parent18b933b88ae3ed470321b2435ddfef0ca117c509
riscv: chunkset_rvv: fix SIGSEGV in CHUNKCOPY

The chunkset_tpl comment allows negative dist (out - from) as long as
the length is smaller than the absolute value of dist (i.e. memory does
not overlap). However this case is currently broken in the RVV override
of CHUNKCOPY -- it compares dist (which is a ptrdiff_t, a value that
should be of the same size with size_t but signed) with the result of
sizeof (which is a size_t), and this triggers the implicit conversion
from signed to unsigned (thus losing negative values).

As it's promised to be not overlapping when dist is negative, just use a
gaint memcpy() call to copy everything.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
arch/riscv/chunkset_rvv.c