From 6c7453db789a428b13b1ee5a3b938e5b69fd1a13 Mon Sep 17 00:00:00 2001 From: "fupan.lfp" Date: Sat, 18 Jan 2020 18:26:01 +0800 Subject: [PATCH] agent: fix the issue of crash agent without spec To check is the oci spec passed in, other wise, it would crash the agent unwrap it directly. Fixes: #124 Signed-off-by: fupan.lfp --- src/agent/src/grpc.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/agent/src/grpc.rs b/src/agent/src/grpc.rs index 441b7120c3..6bc7492e8b 100644 --- a/src/agent/src/grpc.rs +++ b/src/agent/src/grpc.rs @@ -79,7 +79,15 @@ impl agentService { let sandbox; let mut s; - let oci = oci_spec.as_mut().unwrap(); + let oci = match oci_spec.as_mut() { + Some(spec) => spec, + None => { + error!(sl!(), "no oci spec in the create container request!"); + return Err( + ErrorKind::Nix(nix::Error::from_errno(nix::errno::Errno::EINVAL)).into(), + ); + } + }; info!(sl!(), "receive createcontainer {}", &cid);