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.
This commit is contained in:
Lev Vainblat
2026-01-22 15:13:10 +02:00
committed by Gleb Chesnokov
parent a2add2daa3
commit 6c6e7251b2

View File

@@ -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);