Skip to content

Fix: F-12562 - #11935

Open
ohki-saito wants to merge 1 commit into
wolfSSL:masterfrom
ohki-saito:fix/F12562
Open

ohki-saito wants to merge 1 commit into
wolfSSL:masterfrom
ohki-saito:fix/F12562

Conversation

@ohki-saito

Copy link
Copy Markdown
Contributor

Description

Fenrir Finding F-12562

wolfSSL_OCSP_id_get0_info() returns the elements of an OCSP_CERTID. Each call with a serial pointer allocated a new ASN1_INTEGER and stored it in cid->status->serialInt, overwriting the previous one without freeing it. Calling the function more than once with the same cid therefore leaked memory, because only the last allocation is freed with the cid.

This change returns the cached serialInt when it is already set, and only creates a new one on the first call.

Testing

Added a test to test_wolfSSL_OCSP_id_get0_info: calling OCSP_id_get0_info() twice with the same cid must return the same ASN1_INTEGER pointer. Without the fix, the second call returns a newly allocated object and the test fails.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI balanced review requested due to automatic review settings October 30, 2026 06:35
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The serial-number caching change has no active review issues.

No open issues 🎉

What changed in this PR

Fixes F-12562, a memory leak in wolfSSL’s OpenSSL-compatible wolfSSL_OCSP_id_get0_info() when repeatedly requesting the serial number from the same OCSP_CERTID.

Changes:

  • Reuses the cached ASN1_INTEGER, allocating it only on the first request.
  • Adds a regression assertion that repeated calls return the same serial-number pointer.
File Description
tests/​api.c Verifies repeated calls return the cached serial-number pointer.
src/​ocsp.c Reuses serialInt instead of overwriting it with a new allocation.

Review effort: Balanced

@ohki-saito
ohki-saito marked this pull request as ready for review November 6, 2026 08:09
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

retest this please

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m0plus

  • FLASH: .text +40 B (+0.1%, 70,719 B / 262,144 B, total: 27% used)

gcc-arm-cortex-m3

  • FLASH: .text +340 B (+0.3%, 131,677 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4

  • FLASH: .text +668 B (+0.3%, 208,972 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .text +128 B (+0.2%, 73,463 B / 262,144 B, total: 28% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .text +64 B (+0.0%, 181,651 B / 262,144 B, total: 69% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +960 B (+0.5%, 195,928 B / 1,048,576 B, total: 19% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +2,504 B, .text +2,048 B (+0.6%, 800,676 B / 1,048,576 B, total: 76% used)
  • RAM: .bss -12,048 B (-9.0%, 121,772 B / 262,144 B, total: 46% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +64 B (+0.0%, 222,740 B / 262,144 B, total: 85% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +1,088 B (+0.3%, 312,784 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .rodata +8 B, .text +1,216 B (+0.4%, 343,632 B / 1,048,576 B, total: 33% used)
  • RAM: .bss +1,320 B (+7.9%, 17,996 B / 262,144 B, total: 7% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +320 B (+0.2%, 132,433 B / 262,144 B, total: 51% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +832 B (+0.3%, 249,506 B / 262,144 B, total: 95% used)

gcc-arm-cortex-m7

  • FLASH: .text +604 B (+0.3%, 208,972 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +1,024 B (+0.3%, 313,616 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +832 B (+0.3%, 249,506 B / 262,144 B, total: 95% used)

stm32-sim-stm32h753

  • FLASH: .text -832 B (-0.4%, 203,756 B / 2,097,152 B, total: 10% used)

zephyr-frdm_rw612

  • FLASH: log_const_area -8 B, rodata -8 B, text +1,592 B (+0.6%, 284,040 B / 67,108,864 B, total: 0% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

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