From 68d8542c2f458b0efcc5cb39e176f2167dc7ee44 Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Mon, 7 Mar 2022 18:41:45 +0000
Subject: [PATCH] Do not error out on version mismatch in the standard code
 path

---
 auth/callback.go | 4 ++--
 auth/fmt.go      | 8 ++++----
 auth/fmt_test.go | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/auth/callback.go b/auth/callback.go
index a437d834c..2ae9446f1 100644
--- a/auth/callback.go
+++ b/auth/callback.go
@@ -531,7 +531,7 @@ func handleBaseFormat(cmixMsg format.Message, grp *cyclic.Group) (baseFormat,
 
 	baseFmt, err := unmarshalBaseFormat(cmixMsg.GetContents(),
 		grp.GetP().ByteLen())
-	if err != nil {
+	if err != nil && baseFmt == nil {
 		return baseFormat{}, nil, errors.WithMessage(err, "Failed to"+
 			" unmarshal auth")
 	}
@@ -542,5 +542,5 @@ func handleBaseFormat(cmixMsg format.Message, grp *cyclic.Group) (baseFormat,
 	}
 	partnerPubKey := grp.NewIntFromBytes(baseFmt.pubkey)
 
-	return baseFmt, partnerPubKey, nil
+	return *baseFmt, partnerPubKey, nil
 }
diff --git a/auth/fmt.go b/auth/fmt.go
index f267945be..cf38aaed4 100644
--- a/auth/fmt.go
+++ b/auth/fmt.go
@@ -65,18 +65,18 @@ func buildBaseFormat(data []byte, pubkeySize int) baseFormat {
 	return f
 }
 
-func unmarshalBaseFormat(b []byte, pubkeySize int) (baseFormat, error) {
+func unmarshalBaseFormat(b []byte, pubkeySize int) (*baseFormat, error) {
 	if len(b) < pubkeySize {
-		return baseFormat{}, errors.New("Received baseFormat too small")
+		return nil, errors.New("Received baseFormat too small")
 	}
 	bfmt := buildBaseFormat(b, pubkeySize)
 	version := bfmt.GetVersion()
 	if version != requestFmtVersion {
-		return baseFormat{}, errors.Errorf(
+		return &bfmt, errors.Errorf(
 			"Unknown baseFormat version: %d", version)
 	}
 
-	return bfmt, nil
+	return &bfmt, nil
 }
 
 func (f baseFormat) Marshal() []byte {
diff --git a/auth/fmt_test.go b/auth/fmt_test.go
index 64785b399..30580ec1b 100644
--- a/auth/fmt_test.go
+++ b/auth/fmt_test.go
@@ -151,10 +151,10 @@ func TestBaseFormat_MarshalUnmarshal(t *testing.T) {
 			"Could not unmarshal into baseFormat: %v", err)
 	}
 
-	if !reflect.DeepEqual(newMsg, baseMsg) {
+	if !reflect.DeepEqual(*newMsg, baseMsg) {
 		t.Errorf("unmarshalBaseFormat() error: "+
 			"Unmarshalled message does not match originally marshalled message."+
-			"\n\tExpected: %v\n\tRecieved: %v", baseMsg, newMsg)
+			"\n\tExpected: %v\n\tRecieved: %v", baseMsg, *newMsg)
 	}
 
 	// Unmarshal error test: Invalid size parameter
-- 
GitLab