From 3dc6d44c41db09d4d62f89399807efa50e3e0ddc Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Sun, 21 Oct 2018 10:46:04 -0700 Subject: [PATCH] throw error if versions are incompatible --- src/croc/recipient.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/croc/recipient.go b/src/croc/recipient.go index 78ac5a17..d88afef4 100644 --- a/src/croc/recipient.go +++ b/src/croc/recipient.go @@ -108,8 +108,14 @@ func (cr *Croc) receive(forceSend int, serverAddress string, tcpPorts []string, cr.OtherIP = initialData.IPAddress log.Debugf("sender IP: %s", cr.OtherIP) - // TODO: // check whether the version strings are compatible + versionStringsOther := strings.Split(initialData.VersionString, ".") + versionStringsSelf := strings.Split(cr.Version, ".") + if len(versionStringsOther) == 3 && len(versionStringsSelf) == 3 { + if versionStringsSelf[0] != versionStringsOther[0] || versionStringsSelf[1] != versionStringsOther[1] { + return fmt.Errorf("version sender %s is not compatible with recipient %s", cr.Version, initialData.VersionString) + } + } // initialize the PAKE with the curve sent from the sender Q, err = pake.InitCurve(pw, 1, initialData.CurveType, 1*time.Millisecond)