Skip to content

Conversation

@romange
Copy link
Collaborator

@romange romange commented Jan 21, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 21, 2026 16:23
@romange romange requested a review from kostasrim January 21, 2026 16:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR renames and enhances the listpack validation function in the Redis stream implementation, adding more comprehensive checks to detect corrupted listpacks earlier in stream operations.

Changes:

  • Renamed checkListPackNotEmpty to checkListPackValid to better reflect expanded validation scope
  • Added validation for corrupted listpack headers (zero-byte listpacks)
  • Added validation using lpValidateFirst and lpValidateNext to check listpack integrity
  • Applied the enhanced validation at three call sites in stream trimming and entry removal operations

Comment on lines 284 to 295
fprintf(stderr, "Error: corrupted listpack header found.");
abort();
}
p = lpValidateFirst(lp);
if(p[0] == 0xFF) {
fprintf(stderr, "Error: empty listpack found.");
abort();
}

if (lpValidateNext(lp, &p, lpBytes(lp)) == 0) {
lpRepr(lp);
fprintf(stderr, "Error: corrupted listpack found.");
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

Missing newline character in error message. The error messages should end with '\n' to ensure proper formatting when written to stderr. This applies to the error messages on lines 284, 289, and 295.

Suggested change
fprintf(stderr, "Error: corrupted listpack header found.");
abort();
}
p = lpValidateFirst(lp);
if(p[0] == 0xFF) {
fprintf(stderr, "Error: empty listpack found.");
abort();
}
if (lpValidateNext(lp, &p, lpBytes(lp)) == 0) {
lpRepr(lp);
fprintf(stderr, "Error: corrupted listpack found.");
fprintf(stderr, "Error: corrupted listpack header found.\n");
abort();
}
p = lpValidateFirst(lp);
if(p[0] == 0xFF) {
fprintf(stderr, "Error: empty listpack found.\n");
abort();
}
if (lpValidateNext(lp, &p, lpBytes(lp)) == 0) {
lpRepr(lp);
fprintf(stderr, "Error: corrupted listpack found.\n");

Copilot uses AI. Check for mistakes.
Comment on lines 282 to 293
if(lpBytes(lp) == 0) {
fprintf(stderr, "Error: corrupted listpack header found.");
abort();
}
p = lpValidateFirst(lp);
if(p[0] == 0xFF) {
fprintf(stderr, "Error: empty listpack found.");
abort();
}

if (lpValidateNext(lp, &p, lpBytes(lp)) == 0) {
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

Inconsistent code style: missing spaces after 'if' keyword. The code should follow consistent formatting with space after 'if', like 'if (' instead of 'if(' as seen on lines 283, 288, and 293.

Copilot uses AI. Check for mistakes.
@augmentcode
Copy link

augmentcode bot commented Jan 21, 2026

🤖 Augment PR Summary

Summary: Hardens stream listpack validation in t_stream.c by replacing checkListPackNotEmpty with a more comprehensive checkListPackValid.
Changes: Adds header/emptiness checks and invokes listpack entry validation before reading or reinserting listpacks during stream trimming and iterator entry removal.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Copilot AI review requested due to automatic review settings January 21, 2026 16:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment on lines +281 to 298
void checkListPackValid(unsigned char* lp) {
unsigned char* p = NULL;
if(lpBytes(lp) == 0) {
fprintf(stderr, "Error: corrupted listpack found.");
fprintf(stderr, "Error: corrupted listpack header found.\n");
abort();
}
p = lpValidateFirst(lp);
if(p == NULL) {
fprintf(stderr, "Error: empty listpack found.\n");
abort();
}

if (lpValidateNext(lp, &p, lpBytes(lp)) == 0) {
lpRepr(lp);
fprintf(stderr, "Error: corrupted listpack found.\n");
abort();
}
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The validation logic only checks the first entry of the listpack, not the entire structure. After lpValidateFirst returns a pointer to the first element, lpValidateNext validates that element and advances the pointer to the next one, but doesn't continue validating subsequent entries. This means corrupted data in entries after the first one would not be detected. Consider validating all entries or at least a representative sample, similar to how streamValidateListpackIntegrity does it.

Copilot uses AI. Check for mistakes.
Comment on lines +281 to 297
void checkListPackValid(unsigned char* lp) {
unsigned char* p = NULL;
if(lpBytes(lp) == 0) {
fprintf(stderr, "Error: corrupted listpack found.");
fprintf(stderr, "Error: corrupted listpack header found.\n");
abort();
}
p = lpValidateFirst(lp);
if(p == NULL) {
fprintf(stderr, "Error: empty listpack found.\n");
abort();
}

if (lpValidateNext(lp, &p, lpBytes(lp)) == 0) {
lpRepr(lp);
fprintf(stderr, "Error: corrupted listpack found.\n");
abort();
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

Inconsistent code formatting: the function body uses 2-space indentation while the surrounding code uses 4-space indentation. Missing space after if keywords on lines 283 and 288 (should be if ( not if().

Copilot uses AI. Check for mistakes.

void checkListPackNotEmpty(unsigned char* lp) {
void checkListPackValid(unsigned char* lp) {
unsigned char* p = NULL;
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The variable p is initialized to NULL on line 282 but this initialization is unnecessary since it's immediately reassigned on line 287. Consider removing the initialization or declaring the variable where it's first assigned.

Suggested change
unsigned char* p = NULL;
unsigned char* p;

Copilot uses AI. Check for mistakes.
@romange
Copy link
Collaborator Author

romange commented Jan 22, 2026

I do not think we will need this PR

@romange romange removed the request for review from kostasrim January 22, 2026 05:49
@romange romange closed this Jan 30, 2026
@romange romange deleted the Pr6 branch January 30, 2026 08:24
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