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

refuse to work when message ID is all 0s

parent 6af1b074
No related branches found
No related tags found
2 merge requests!60Revert "Fail a test to be sure it works",!8Updates to match the client fullyDecentrilizedChannels branch
......@@ -160,10 +160,23 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID,
if err != nil {
jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
}
if checkZero(messageID.Bytes()) {
jww.FATAL.Panicf("Empty message ID is impossible!")
}
go w.receivedMessageCB(uuid, channelID)
return uuid
}
func checkZero(b []byte) bool {
for i := 0; i < len(b); i++ {
if b[i] != 0 {
return false
}
}
return true
}
// ReceiveReply is called whenever a message is received that is a reply on a
// given channel. It may be called multiple times on the same message; it is
// incumbent on the user of the API to filter such called by message ID.
......@@ -183,6 +196,9 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID,
if err != nil {
jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
}
if checkZero(messageID.Bytes()) {
jww.FATAL.Panicf("Empty message ID is impossible!")
}
go w.receivedMessageCB(uuid, channelID)
return uuid
}
......@@ -205,6 +221,9 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.Me
if err != nil {
jww.ERROR.Printf("%+v", errors.Wrap(parentErr, err.Error()))
}
if checkZero(messageID.Bytes()) {
jww.FATAL.Panicf("Empty message ID is impossible!")
}
go w.receivedMessageCB(uuid, channelID)
return uuid
}
......@@ -246,6 +265,9 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64, messageID cryptoChannel.Messag
}
channelID := &id.ID{}
copy(channelID[:], newMessage.ChannelID)
if checkZero(messageID.Bytes()) {
jww.FATAL.Panicf("Empty message ID is impossible!")
}
go w.receivedMessageCB(uuid, channelID)
}
......
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