From 245616747e8b9fe9068023d46459a41624b7b114 Mon Sep 17 00:00:00 2001 From: Rob Hoes Date: Mon, 17 Apr 2023 16:32:06 +0000 Subject: [PATCH] CA-376448: explicitly validate refs in PVS_cache_storage.create In particular, if the host parameter is left out from the call, a null ref is used and put into the new PVS_cache_storage object. The DB GC will then destroy the object when it runs next, due to the invalid ref, but it is better to fail the create call immediately. Signed-off-by: Rob Hoes --- ocaml/xapi/xapi_pvs_cache_storage.ml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ocaml/xapi/xapi_pvs_cache_storage.ml b/ocaml/xapi/xapi_pvs_cache_storage.ml index 9c81cd5ad24..87530149fd0 100644 --- a/ocaml/xapi/xapi_pvs_cache_storage.ml +++ b/ocaml/xapi/xapi_pvs_cache_storage.ml @@ -29,6 +29,9 @@ let assert_not_already_present ~__context site host = api_error E.pvs_cache_storage_already_present [str site; str host] let create ~__context ~host ~sR ~site ~size = + Helpers.assert_is_valid_ref ~__context ~name:"host" ~ref:host ; + Helpers.assert_is_valid_ref ~__context ~name:"SR" ~ref:sR ; + Helpers.assert_is_valid_ref ~__context ~name:"site" ~ref:site ; assert_not_already_present ~__context site host ; let cache_storage = Ref.make () in let uuid = Uuidx.(to_string (make ())) in