Skip to content
Snippets Groups Projects
Commit 68d8542c authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Do not error out on version mismatch in the standard code path

parent 4469f724
No related branches found
No related tags found
3 merge requests!231Revert "Update store to print changes to the partners list",!187Xx 3829/triggers,!179Decrypt old auth channel request packets
......@@ -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
}
......@@ -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 {
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment