From f75cdd0ad8db47b2a4fac0216e0e50f30c3c5f21 Mon Sep 17 00:00:00 2001 From: Ruoyu Ying Date: Mon, 22 Apr 2024 14:59:47 +0800 Subject: [PATCH] vmsdk: add error handling for get_cc_report in go * Handle the case on corrupted generation in configfs-tsm --- src/golang/cctrusted_vm/cvm.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/golang/cctrusted_vm/cvm.go b/src/golang/cctrusted_vm/cvm.go index 820ba30..1297e95 100644 --- a/src/golang/cctrusted_vm/cvm.go +++ b/src/golang/cctrusted_vm/cvm.go @@ -78,6 +78,10 @@ func (d *GenericDevice) Report(nonce, userData string, extraArgs map[string]any) return cctrusted_base.CcReport{}, errors.New("Failed to get generation info.") } generation, _ = strconv.Atoi(string(rawGeneration)) + // Check if the outblob has been corrupted during file open + if generation > 1 { + return cctrusted_base.CcReport{}, errors.New("Found corrupted generation.") + } } if _, err = os.Stat(filepath.Join(tempdir, "provider")); !os.IsNotExist(err) {