Skip to content

Eliminate dead code. - #326

Merged
jbdelcuv merged 2 commits into
mainfrom
personal/jbdelcuv/dead_code_elimination
Sep 2, 2026
Merged

jbdelcuv merged 2 commits into
mainfrom
personal/jbdelcuv/dead_code_elimination

Conversation

@jbdelcuv

@jbdelcuv jbdelcuv commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Eliminate dead code in RAND_priv_bytes_ex and RAND_priv_bytes.

Signed-off-by: Juan del Cuvillo <juan.b.del.cuvillo@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread openssl_source/rand_lib.c Outdated
Signed-off-by: Juan del Cuvillo <juan.b.del.cuvillo@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_MAX guard is after the legacy meth->bytes() early return, so large num values can still be truncated when passed to meth->bytes()/get_sgx_rand_bytes. Validate num before the legacy call and cast to (int)num only 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

Comment thread openssl_source/rand_lib.c
@jbdelcuv
jbdelcuv merged commit 6ec2ed4 into main Sep 2, 2026
4 checks passed
@jbdelcuv
jbdelcuv deleted the personal/jbdelcuv/dead_code_elimination branch September 2, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants