bitlbee / bitlbee-facebook

Facebook protocol plugin for BitlBee
GNU General Public License v2.0
279 stars 49 forks source link

unexpected identifier `taNewMessage', expected value #200

Closed raidancampbell closed 3 years ago

raidancampbell commented 3 years ago

First noticed at 2020-10-17 at 8:51 AM MST, whenever a new message is received, the following error is shown: Error: <data>:1:12: Parse error: unexpected identifier 'taNewMessage', expected value. bitlbee-facebook then signs off and reconnects after 5 seconds.

The message is read and placed in the channel, but due to the deconn/reconn, the channel gets polluted with status messages.

I'm using commit 5930cfec4361e52ff43a606fda5d4621e9cb607d of mbologna's docker-bitlbee repo, which references release 1.2.0 of bitlbee-facebook

Thaodan commented 3 years ago

I have the same probem im also using the same version but without docker.

nuxi commented 3 years ago

I'm also getting this. Same version but from the Debian Sid repos.

nuxi commented 3 years ago

bitlbee isn't the only thing affected: https://github.com/dequis/purple-facebook/issues/496

nuxi commented 3 years ago

Its trying to decode the JSON starting 16 bytes into it. There is a thrift message prepended to all the JSON payloads and when its the 1-byte 0x00 message everything is fine. When I'm getting the crash its a 25-byte message starting with 0x28 and the code is treating it like its a 41-byte message.

I'm trying a build with https://github.com/bitlbee/bitlbee-facebook/pull/198 included to see what happens.

nuxi commented 3 years ago

So I think the problem is right here - https://github.com/bitlbee/bitlbee-facebook/blob/v1.2.0/facebook/facebook-api.c#L1564

This code comes from this commit - https://github.com/bitlbee/bitlbee-facebook/commit/75b3f5b0c29782b8a31009ba6ff2972a5ce736e3

Here is the thrift protocol documentation - https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md#struct

The plugin is treating the data as a thrift string, but its actually a thrift structure. This structure seems to arrive in one of two states: 1) a lone stop field - which happens to do the right thing if its interpreted as a thrift string (it gets treated as a 0-byte string) 2) a string field followed by a stop field

I've made a quick and dirty patch to see if this fixes the problem, if it does I'll clean it up and post PRs for bitlbee-facebook and purple-facebook.

dequis commented 3 years ago

https://github.com/bitlbee/bitlbee-facebook/releases/tag/v1.2.1