Eliminate dead code. - #326
Conversation
Signed-off-by: Juan del Cuvillo <juan.b.del.cuvillo@intel.com>
There was a problem hiding this comment.
🟡 Changes recommended
The dead-code removal leaves RAND_priv_bytes_ex() with unused locals/parameters and a potentially truncating size_t→int conversion, which can break builds under common warning settings and mishandle large requests.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR removes unreachable fallback code from RAND_priv_bytes_ex() so the SGX-specific RDRAND path is the only post-legacy-method execution path.
Changes:
- Removed dead/unreachable private-DRBG generation path after the SGX
get_sgx_rand_bytes()return. - Adjusted the in-code comment wording (“insteadly” → “instead”).
File summaries
| File | Description |
|---|---|
| openssl_source/rand_lib.c | Removes unreachable code in RAND_priv_bytes_ex() to align the function with the SGX RDRAND-only behavior. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Juan del Cuvillo <juan.b.del.cuvillo@intel.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new INT_MAX guard is placed after an early-return legacy RAND_METHOD path, so large requests can still be truncated before reaching the new check.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
openssl_source/rand_lib.c:378
- Same issue as RAND_priv_bytes_ex: the
num > INT_MAXguard is after the legacymeth->bytes()early return, so largenumvalues can still be truncated when passed tometh->bytes()/get_sgx_rand_bytes. Validatenumbefore the legacy call and cast to(int)numonly after the check.
if (num > INT_MAX) {
ERR_raise(ERR_LIB_RAND, RAND_R_REQUEST_TOO_LARGE_FOR_DRBG);
return 0;
}
return get_sgx_rand_bytes(buf, (int)num);
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Eliminate dead code in
RAND_priv_bytes_exandRAND_priv_bytes.