sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.14k stars 209 forks source link

EVP* function results in lib/util/digest_openssl.c are not checked #380

Closed ngie-eign closed 15 hours ago

ngie-eign commented 1 month ago

Coverity reported the fact that the results of EVP_DigestInit_ex and EVP_DigestFinal_ex are not checked. In the event that the md provided is invalid and the corresponding ctx is not checked, attempting to use ctx after the fact can result in semi-undefined behavior (SIGBUS, SIGSEGV crash, etc).

These issues were reported by Coverity.

millert commented 1 month ago

This is a false positive. The call to EVP_DigestInit_ex() in sudo_digest_alloc_v1() is checked. The call in sudo_digest_reset_v1() is not checked because it cannot fail since it is preceded by a call to EVP_MD_CTX_reset() so there is no additional memory to allocate. The md in the call to EVP_DigestFinal_ex() is a result variable, it is not a EVP_MD. Even if EVP_DigestFinal_ex() were to fail it would just fail to fill in md, not crash.