-
Notifications
You must be signed in to change notification settings - Fork 23.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sanitize dump payload for HFE #13278
Conversation
if ((uint64_t)expire_at < data->last_expireat) return 0; | ||
data->last_expireat = expire_at; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea: maybe lpValidateIntegrity
can get an array of entry validation functions instead of a single pointer, where each such validation callback will have its own opaque data and the offset at which it should be called, from 0 to tuple_len (tuple_len is a special case for all entries, or -1 can be used for that instead).
So the validation function will be called only when reaching an entry in the listpack for which idx % tuple_len == offset, for example, if the tuple_len is 3 and the offset is 2, it will only be called for the TTL entries.
IMHO this will be a more generic approach, in which the same CB is not shared for validating different object types.
You can pass an array of such structs instead of the CB and data to lpValidateIntegrity
:
typedef struct { listpackValidateEntryCB entry_cb; void *cb_userdata; int offset; } listpackEntryValidator;
And then we can have one validator for filed uniqueness and one validator for TTL validity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good idea, however it also bring a lot of changes, and all lpValidateIntegrity*
methods will be changed.
i still want to leave it as now, and optimize it in the future if it doesn't meet the needs.
i started by simply copying a new lpexValidateIntegrity, then i chose to put the TTL fields validation in _lpEntryValidation
because i thought it would be the least chage.
Co-authored-by: Ozan Tezcan <ozantezcan@gmail.com>
Co-authored-by: Ozan Tezcan <ozantezcan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Add the following validations:
Other:
Fix the missing of handling OBJ_ENCODING_LISTPACK_EX in dismissHashObject().