Skip to content

Commit

Permalink
u3: improve snapshot corruption size checks (#468)
Browse files Browse the repository at this point in the history
These checks were introduced in v2.7, aborting the process if the
snapshot metadata indicated that truncation had occurred. But the check
as written is unnecessarily strict, and also aborts the process if the
snapshot was larger than necessary. This PR prints a warning in that
case and otherwise continues.
  • Loading branch information
joemfb authored Jun 22, 2023
2 parents f54d6de + 272bb84 commit 9fac623
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/noun/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,19 @@ _find_home(void)
nor_w = (low_p + ((1 << u3a_page) - 1)) >> u3a_page;
sou_w = u3P.pag_w - (hig_p >> u3a_page);

if ( (nor_w != u3P.nor_u.pgs_w) || (sou_w != u3P.sou_u.pgs_w) ) {
if ( (nor_w > u3P.nor_u.pgs_w) || (sou_w != u3P.sou_u.pgs_w) ) {
fprintf(stderr, "loom: corrupt size north (%u, %u) south (%u, %u)\r\n",
nor_w, u3P.nor_u.pgs_w, sou_w, u3P.sou_u.pgs_w);
u3_assert(!"loom: corrupt size");
}

// the north segment is in-order on disk; it being oversized
// doesn't necessarily indicate corruption.
//
if ( nor_w < u3P.nor_u.pgs_w ) {
fprintf(stderr, "loom: strange size north (%u, %u)\r\n",
nor_w, u3P.nor_u.pgs_w);
}
}

/* As a further guard against any sneaky loom corruption */
Expand Down

0 comments on commit 9fac623

Please sign in to comment.