mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Validate serialized info timestamps in content file parser to prevent 64-bit overflow
This commit is contained in:
parent
e0c0ea3dcc
commit
0277da9178
1 changed files with 18 additions and 0 deletions
|
|
@ -2541,6 +2541,15 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* ensure the unsigned serialized timestamp fits in signed time_t before conversion. */
|
||||
if (v_oldest > INT64_MAX) {
|
||||
/* LCOV_EXCL_START */
|
||||
decoding_error(path, f);
|
||||
log_fatal(ECONTENT, "Internal inconsistency: Invalid info oldest timestamp %" PRIu64 "!\n", v_oldest);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
v_pos = 0;
|
||||
while (v_pos < blockmax) {
|
||||
int bad;
|
||||
|
|
@ -2585,6 +2594,15 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* ensure the timestamp addition fits in signed time_t without overflow. */
|
||||
if (t64 > INT64_MAX - v_oldest) {
|
||||
/* LCOV_EXCL_START */
|
||||
decoding_error(path, f);
|
||||
log_fatal(ECONTENT, "Internal inconsistency: Invalid info timestamp %" PRIu64 "!\n", t64);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* analyze the flags */
|
||||
bad = (flag & 2) != 0;
|
||||
rehash = (flag & 4) != 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue