From a25d0e2c7d1e1fcd85ff5d211b4b5b83bc280e13 Mon Sep 17 00:00:00 2001 From: Lev Vainblat Date: Thu, 22 Jan 2026 15:13:10 +0200 Subject: [PATCH] iscsi-scst: Fix wrong variable in chap_calc_digest_af_alg memcpy Use 'bytes' (the return value from af_alg_final) instead of 'res' (which is 0 after the last successful af_alg_update call) when copying the digest. This bug caused the memcpy to copy 0 bytes, resulting in an uninitialized digest buffer. It also triggered a GCC -Werror=stringop-overflow warning because 'res' could theoretically be negative, leading to a huge unsigned size. --- iscsi-scst/usr/chap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iscsi-scst/usr/chap.c b/iscsi-scst/usr/chap.c index 6a344af8d..a881d8bae 100644 --- a/iscsi-scst/usr/chap.c +++ b/iscsi-scst/usr/chap.c @@ -380,7 +380,7 @@ chap_calc_digest_af_alg(char *alg, char chap_id, goto out; } - memcpy(digest, buffer, MIN(res, digest_len)); + memcpy(digest, buffer, MIN(bytes, digest_len)); out: close(datafd);