Skip to content

Commit f15133b

Browse files
committed
fixup! [LibOS] Make handling of corruption more consistent (WIP)
1 parent d850657 commit f15133b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

common/src/protected_files/protected_files.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,10 @@ static file_node_t* ipf_read_data_node(pf_context_t* pf, uint64_t offset) {
643643
if (PF_FAILURE(status)) {
644644
free(file_data_node);
645645
pf->last_error = status;
646-
if (status == PF_STATUS_MAC_MISMATCH)
646+
if (status == PF_STATUS_MAC_MISMATCH) {
647647
pf->file_status = PF_STATUS_CORRUPTED;
648+
pf->last_error = PF_STATUS_CORRUPTED;
649+
}
648650
return NULL;
649651
}
650652

@@ -706,8 +708,10 @@ static file_node_t* ipf_read_mht_node(pf_context_t* pf, uint64_t logical_mht_nod
706708
if (PF_FAILURE(status)) {
707709
free(file_mht_node);
708710
pf->last_error = status;
709-
if (status == PF_STATUS_MAC_MISMATCH)
711+
if (status == PF_STATUS_MAC_MISMATCH) {
710712
pf->file_status = PF_STATUS_CORRUPTED;
713+
pf->last_error = PF_STATUS_CORRUPTED;
714+
}
711715
return NULL;
712716
}
713717

@@ -791,9 +795,11 @@ static bool ipf_init_existing_file(pf_context_t* pf, const char* path) {
791795
if (PF_FAILURE(status)) {
792796
pf->last_error = status;
793797
DEBUG_PF("failed to decrypt metadata: %d", status);
794-
if (status == PF_STATUS_MAC_MISMATCH)
798+
if (status == PF_STATUS_MAC_MISMATCH) {
795799
// MAC could also mismatch if wrong key was provided but we err on side of safety ...
796800
pf->file_status = PF_STATUS_CORRUPTED;
801+
pf->last_error = PF_STATUS_CORRUPTED;
802+
}
797803
return false;
798804
}
799805

@@ -821,8 +827,10 @@ static bool ipf_init_existing_file(pf_context_t* pf, const char* path) {
821827
&pf->metadata_decrypted.root_mht_node_mac);
822828
if (PF_FAILURE(status)) {
823829
pf->last_error = status;
824-
if (status == PF_STATUS_MAC_MISMATCH)
830+
if (status == PF_STATUS_MAC_MISMATCH) {
825831
pf->file_status = PF_STATUS_CORRUPTED;
832+
pf->last_error = PF_STATUS_CORRUPTED;
833+
}
826834
return false;
827835
}
828836
}

0 commit comments

Comments
 (0)