Skip to content

Improve buffer handling during error handling#1496

Merged
jasonkatonica merged 1 commit into
IBM:java21from
jasonkatonica:katonica/issue1345/fixvsprintf-java21
May 27, 2026
Merged

Improve buffer handling during error handling#1496
jasonkatonica merged 1 commit into
IBM:java21from
jasonkatonica:katonica/issue1345/fixvsprintf-java21

Conversation

@jasonkatonica
Copy link
Copy Markdown
Member

  • Replace unsafe vsprintf() with safer vsnprintf() in Utils.c to prevent possible buffer overflows in gslogError(), gslogMessage(), and gslogMessagePrefix() functions
  • Fix incorrect variable references in RSA debug logging which prevents compiling debug code. This results in syntax errors:
    • Use ciphertextLen instead of plaintextLen in RSA.c
    • Use keyBytesNative instead of pBytes in RSAKey.c
  • Improve error handling in ockCheckStatus() by using ICC_ERR_error_string_n() with bounded fixed size buffer. Loop printing exception messages changed to print any error code not just the value 1.
  • Remove unused OpenSSLError() function from CCM.c

These changes enhance security by preventing the potential of a buffer overflow and fix debug logging to display correct variable values.

Fixes #1345

Back-ported from: #1484

Signed-off-by: Jason Katonica katonica@us.ibm.com

- Replace unsafe vsprintf() with safer vsnprintf() in Utils.c to prevent
  possible buffer overflows in gslogError(), gslogMessage(), and
  gslogMessagePrefix() functions
- Fix incorrect variable references in RSA debug logging which prevents
  compiling debug code. This results in syntax errors:
  - Use ciphertextLen instead of plaintextLen in RSA.c
  - Use keyBytesNative instead of pBytes in RSAKey.c
- Improve error handling in ockCheckStatus() by using
  ICC_ERR_error_string_n() with bounded fixed size buffer. Loop printing
  exception messages changed to print any error code not just the
  value `1`.
- Remove unused OpenSSLError() function from CCM.c

These changes enhance security by preventing the potential of a buffer
overflow and fix debug logging to display correct variable values.

Fixes IBM#1345

Back-ported from: IBM#1484

Signed-off-by: Jason Katonica <katonica@us.ibm.com>
Copy link
Copy Markdown
Member

@KostasTsiounis KostasTsiounis left a comment

Choose a reason for hiding this comment

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

LGTM

@jasonkatonica jasonkatonica merged commit 09358aa into IBM:java21 May 27, 2026
3 checks passed
@jasonkatonica jasonkatonica deleted the katonica/issue1345/fixvsprintf-java21 branch May 27, 2026 17:11
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.

3 participants