coyim / otr3

A Go implementation of the OTR 3 protocol, with libotr 4.1.0 feature parity
GNU General Public License v3.0
70 stars 14 forks source link

Do deep copy of MessagePlaintext in resend.go. #52

Closed unkaktus closed 7 years ago

unkaktus commented 7 years ago

Not doing so led to sending of zero-filled messages. This bug was introduced in 0f024454fd8a29bb7b59ca00515b67f8328a6151.

btw, what's the reason for MessagePlaintext being []byte and not string?

unkaktus commented 7 years ago

There may be other related bugs.

olabini commented 7 years ago

Great, thanks!

MessagePlaintext is []byte because otr3 can send arbitrary messages, including binary data. string doesn't really suit this well.

unkaktus commented 7 years ago

Hm, this doesn't sound right to me. According to the specs plaintext is not arbitrary:

The plaintext message (either before encryption, or after decryption) consists of a human-readable message (encoded in UTF-8, optionally with HTML markup), optionally followed by: a single NUL (a BYTE with value 0x00), and ...

It should be in UTF-8 and must not contain NUL byte - it will corrupt TLV data otherwise (e.g. it did so due to this bug). So to conform the specs API should accept string for plaintext message and then encode it into UTF-8 to put it into Data Message.