Skip to content

[#1778] Guard NULL pointers and clear freed outputs in LZ4 string helpers - #1779

Closed
hardikkaurani wants to merge 1 commit into
pgmoneta:mainfrom
hardikkaurani:fix/lz4-string-null-and-dangling-ptr
Closed

hardikkaurani wants to merge 1 commit into
pgmoneta:mainfrom
hardikkaurani:fix/lz4-string-null-and-dangling-ptr

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Closes #1778

Summary

  • Validate s, buffer, and buffer_size for NULL in pgmoneta_lz4c_string() (src/libpgmoneta/lz4_compression.c), initialize *buffer = NULL and *buffer_size = 0, and reset *buffer = NULL after free(*buffer) on error paths.
  • Validate compressed_buffer and output_string for NULL in pgmoneta_lz4d_string(), initialize *output_string = NULL, and reset *output_string = NULL after free(*output_string) on decompression failure.
  • Add MCTF_TEST_NEGATIVE(test_lz4_string_null_and_invalid) in test/testcases/test_compression.c.

Verification

  • Verified formatting with clang-format --dry-run --Werror.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

@jesperpedersen @Pranav-error Hi, this PR addresses #1778 in src/libpgmoneta/lz4_compression.c:

  • Validates s, buffer, and buffer_size in pgmoneta_lz4c_string() and compressed_buffer / output_string in pgmoneta_lz4d_string() for NULL before dereferencing.
  • Initializes output pointers upfront and resets *buffer = NULL / *output_string = NULL after free() on error paths so callers never observe dangling pointers.
  • Adds MCTF_TEST_NEGATIVE(test_lz4_string_null_and_invalid) in test/testcases/test_compression.c.

Formatting passes clang-format --dry-run --Werror and the PR is a single signed-off commit.

@ecleon26

ecleon26 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

@hardikkaurani Combine with #1781

@ecleon26 ecleon26 closed this Dec 1, 2026
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.

lz4_compression: missing NULL checks and dangling output pointers in string helpers

3 participants