Skip to content

Commit

Permalink
fixup! [LibOS] Make handling of corruption more consistent (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
g2flyer committed Aug 26, 2024
1 parent d850657 commit f15133b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions common/src/protected_files/protected_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,10 @@ static file_node_t* ipf_read_data_node(pf_context_t* pf, uint64_t offset) {
if (PF_FAILURE(status)) {
free(file_data_node);
pf->last_error = status;
if (status == PF_STATUS_MAC_MISMATCH)
if (status == PF_STATUS_MAC_MISMATCH) {
pf->file_status = PF_STATUS_CORRUPTED;
pf->last_error = PF_STATUS_CORRUPTED;
}
return NULL;
}

Expand Down Expand Up @@ -706,8 +708,10 @@ static file_node_t* ipf_read_mht_node(pf_context_t* pf, uint64_t logical_mht_nod
if (PF_FAILURE(status)) {
free(file_mht_node);
pf->last_error = status;
if (status == PF_STATUS_MAC_MISMATCH)
if (status == PF_STATUS_MAC_MISMATCH) {
pf->file_status = PF_STATUS_CORRUPTED;
pf->last_error = PF_STATUS_CORRUPTED;
}
return NULL;
}

Expand Down Expand Up @@ -791,9 +795,11 @@ static bool ipf_init_existing_file(pf_context_t* pf, const char* path) {
if (PF_FAILURE(status)) {
pf->last_error = status;
DEBUG_PF("failed to decrypt metadata: %d", status);
if (status == PF_STATUS_MAC_MISMATCH)
if (status == PF_STATUS_MAC_MISMATCH) {
// MAC could also mismatch if wrong key was provided but we err on side of safety ...
pf->file_status = PF_STATUS_CORRUPTED;
pf->last_error = PF_STATUS_CORRUPTED;
}
return false;
}

Expand Down Expand Up @@ -821,8 +827,10 @@ static bool ipf_init_existing_file(pf_context_t* pf, const char* path) {
&pf->metadata_decrypted.root_mht_node_mac);
if (PF_FAILURE(status)) {
pf->last_error = status;
if (status == PF_STATUS_MAC_MISMATCH)
if (status == PF_STATUS_MAC_MISMATCH) {
pf->file_status = PF_STATUS_CORRUPTED;
pf->last_error = PF_STATUS_CORRUPTED;
}
return false;
}
}
Expand Down

0 comments on commit f15133b

Please sign in to comment.