8000
Skip to content

x509.name.new: guard against non-table array elements (nil deref crash) - #414

Open
samchang8826 wants to merge 1 commit into
zhaozg:v0.xfrom
OpenLuan:luan-eaa7923
Open

x509.name.new: guard against non-table array elements (nil deref crash)#414
samchang8826 wants to merge 1 commit into
zhaozg:v0.xfrom
OpenLuan:luan-eaa7923

Conversation

@samchang8826
@samchang8826 samchang8826 commented Aug 21, 2026
Copy link
Copy Markdown

x509.name.new{ "CN=x" } (array of strings) passed the luaL_checktable + rawlen>0 checks in openssl_xname_new, then openssl_new_xname ran lua_next on the string element, treating it as a table -> luaH_next dereferenced a NULL array pointer and crashed the whole process (pcall cannot catch a segfault).

Check each array element with lua_istable before iterating it, and return nil+error instead of crashing.

Description

Please provide a clear and concise description of your changes.

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Code review/analysis
  • Performance improvement
  • Code refactoring
  • Other (please describe)

Changes Made

Please list the specific changes made in this PR:

Testing

Please describe the tests you ran to verify your changes:

  • Existing tests pass
  • Added new tests
  • Manual testing performed

Checklist

  • My code follows the style guidelines of this project (clang-format)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

OpenSSL Compatibility

Please indicate which OpenSSL versions were tested (if applicable):

  • OpenSSL 1.0.2u
  • OpenSSL 1.1.1w
  • OpenSSL 3.0.x
  • OpenSSL 3.5+
  • LibreSSL 3.3.6+

Additional Notes

Add any other context about the pull request here.


For development roadmap and planning, see:

x509.name.new{ "CN=x" } (array of strings) passed the luaL_checktable +
rawlen>0 checks in openssl_xname_new, then openssl_new_xname ran lua_next
on the string element, treating it as a table -> luaH_next dereferenced a
NULL array pointer and crashed the whole process (pcall cannot catch a
segfault).

Check each array element with lua_istable before iterating it, and return
nil+error instead of crashing.
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.

1 participant

0