Skip to content

Improve buffer handling during error handling#1484

Merged
jasonkatonica merged 1 commit into
IBM:mainfrom
jasonkatonica:katonica/issue1345/fixvsprintf
May 26, 2026
Merged

Improve buffer handling during error handling#1484
jasonkatonica merged 1 commit into
IBM:mainfrom
jasonkatonica:katonica/issue1345/fixvsprintf

Conversation

@jasonkatonica
Copy link
Copy Markdown
Member

@jasonkatonica jasonkatonica commented May 20, 2026

  • 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

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

@jasonkatonica jasonkatonica changed the title Imporve buffer handling during error handling Improve buffer handling during error handling May 20, 2026
- 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

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

Copy link
Copy Markdown
Collaborator

@taoliult taoliult left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@JinhangZhang JinhangZhang 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 d951112 into IBM:main May 26, 2026
3 checks passed
@jasonkatonica jasonkatonica deleted the katonica/issue1345/fixvsprintf branch May 26, 2026 12:45
jasonkatonica added a commit that referenced this pull request May 27, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 27, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 27, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 27, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 27, 2026
- 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>
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.

Fix issues in Utils.c identified by the static code analyzer.

5 participants