libgcrypt icon indicating copy to clipboard operation
libgcrypt copied to clipboard

random-drbg: fix missing error check from _gcry_rngdrbg_cavs_test()

Open AntonMoryakov opened this issue 7 months ago • 0 comments

The return value of _gcry_rngdrbg_cavs_test() was immediately overwritten by memcmp() result, leading to potential loss of error information. This could cause the health check to succeed even if the internal CAVS test function failed.

This issue was reported by a static analyzer:

Return value of function '_gcry_rngdrbg_cavs_test' passed to 'ret' at random-drbg.c:2378 will be rewritten later.

To fix this, we now check the return code of _gcry_rngdrbg_cavs_test() and only call memcmp() if the test execution succeeded.

AntonMoryakov avatar Jun 01 '25 19:06 AntonMoryakov