From d3a188fb8e574d9d7ce98592dc3fc76483734167 Mon Sep 17 00:00:00 2001 From: Nicolas Bouffard Date: Wed, 29 May 2024 16:09:55 +0200 Subject: [PATCH] fix: avoid panic due to interface conversion without check --- ios/tunnel/untrusted.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ios/tunnel/untrusted.go b/ios/tunnel/untrusted.go index c6aada0e..7e13848a 100644 --- a/ios/tunnel/untrusted.go +++ b/ios/tunnel/untrusted.go @@ -144,7 +144,14 @@ func (t *tunnelService) createTunnelListener() (tunnelListener, error) { return tunnelListener{}, err } port := createListener["port"].(float64) - devPublicKey := createListener["devicePublicKey"].(string) + devPublicKeyRaw, found := createListener["devicePublicKey"] + if !found { + return tunnelListener{}, fmt.Errorf("no public key found") + } + devPublicKey, isString := devPublicKeyRaw.(string) + if !isString { + return tunnelListener{}, fmt.Errorf("public key is not a string") + } devPK, err := base64.StdEncoding.DecodeString(devPublicKey) if err != nil { return tunnelListener{}, err