From 6148852131b216dd1def5a5c7fee6863b3f88269 Mon Sep 17 00:00:00 2001
From: jiangpengfei <jiangpengfei9@huawei.com>
Date: Tue, 15 Dec 2020 12:29:21 -0500
Subject: [PATCH] kata-runtime: fix validInterface func cause crash problem

reason: fix validInterface func crach problem which is found
by the fuzz testcase.

Conflict: NA
Reference:https://gitee.com/src-openeuler/kata-containers
Change-Id: I41d65d6c4bf44175c0ff74e6600447cf2ad6e422
Signed-off-by: jiangpengfei <jiangpengfei9@huawei.com>
---
 virtcontainers/network.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/virtcontainers/network.go b/virtcontainers/network.go
index 15eb790..89c5ce3 100644
--- a/virtcontainers/network.go
+++ b/virtcontainers/network.go
@@ -1532,6 +1532,10 @@ func validInterface(inf *vcTypes.Interface, enableCompatOldCNI bool) error {
 		if len(inf.IPAddresses) != 1 {
 			return fmt.Errorf("only one IP address is supported currently")
 		}
+
+		if inf.IPAddresses[0] == nil {
+			return fmt.Errorf("input IP address info should not be null")
+		}
 		_, err := verifyIP(inf.IPAddresses[0].Address)
 		if err != nil {
 			return err
-- 
1.8.3.1

