Skip to content

Fix zero-length MSI signature blob handling - #531

Merged
mtrojnar merged 1 commit into
masterfrom
fix/msi-zero-length-copy
Nov 6, 2026
Merged

mtrojnar merged 1 commit into
masterfrom
fix/msi-zero-length-copy

Conversation

@mtrojnar

@mtrojnar mtrojnar commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Pull Request Type

  • Bug fix
  • New feature
  • Code style / formatting / renaming
  • Refactoring (no functional or API changes)
  • Build / CI related changes
  • Documentation
  • Other (please describe):

Related Issue

Issue number: N/A

Current Behavior

stream_read() allocates and copies DigitalSignature and MsiDigitalSignatureEx blobs even when their length is zero. In the MsiDigitalSignatureEx path the source pointer can then be NULL, and memcpy() with a NULL source is undefined behavior that UBSAN rejects, aborting the attach/remove operation.

New Behavior

An empty signature blob now skips allocation and copying; the data pointer is left NULL.

Scope of Changes

Only stream_read() in msi.c.

Testing

  • Existing tests
  • New tests added
  • Manual testing

Built with ASAN+UBSAN together with the separate little-endian shift fix from #530 (the same reproducers also hit that independent UBSAN issue). All 57 attach/remove crash inputs then complete without the null-memcpy report.

Additional Notes

Pre-existing issue found by fuzzing. It is undefined behavior rather than a memory write; the validation above needs #530 for a sanitizer-clean run of these particular inputs.

License Declaration

  • I hereby agree to license my contribution under the project's license.

stream_read() allocates and copies DigitalSignature and
MsiDigitalSignatureEx blobs even when their length is zero. In the
MsiDigitalSignatureEx path the source pointer can then be NULL, and
memcpy() with a NULL source is undefined behavior that UBSAN rejects.

Skip the allocation and copy when the blob is empty.

@olszomal olszomal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me.

@mtrojnar
mtrojnar merged commit 75a3c02 into master Nov 6, 2026
10 checks passed
@mtrojnar
mtrojnar deleted the fix/msi-zero-length-copy branch November 6, 2026 11:04
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.

2 participants