tiny: Tiny panicks when connecting to irc.gitter.im
Maybe I didn’t configure it correctly, but if so I couldn’t find what parameter is wrong and causing this issue:
thread 'main' panicked at 'byte index 13 is out of bounds of ` 1.10.0`', /rust/47c3158c3d797f75f0f7b2b2a977179668919dab/src/libcore/str/mod.rs:2052:47
- addr: irc.gitter.im
port: 6697
tls: true
realname: Kabouik
nicks: [Kabouik]
# (optional) Server alias for display in tab line
alias: Gitter
# Channels to automatically join
join:
- '#jarun/nnn'
# Server or nick password
pass: 'mytoken'
I tried with or without nicknames listed in nicks, with or without the channel, but no difference.
I followed instructions at https://irc.gitter.im/.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (10 by maintainers)
I can reproduce this locally.
First of all here’s a problem with tiny that is not specific to this bug: in case of a panic in a task we should really abort. I don’t know how tiny can continue operating after a panic (after all, we don’t spawn any threads, and AFAIK you can only catch panics in thread boundaries), but it clearly can, as otherwise there would be at most one panic reported in stderr in a panic.
Currently I get three panics, I think only the first one is relevant (others are chain reaction) so only pasting that:
Backtrace
The bug is in this function:
Here the magic number
13is the length of string"Your host is ". This assumes that RPL_YOURHOST messages always start with that prefix. This is per RFC 2812, which defines response format asApparently this server doesn’t follow this format.
The function
parse_servernameis very fragile and we should make sure to check all bounds here. I’ll update the code.Reminder: the server name parsed in this function is used when pinging the server when we don’t hear from it for a while. If we can’t parse server name of a server then
send_pingsimply returns.The
paramslook incorrectly parsed where thedebug_assertis panicking.params["trevarj", "Gitter", "trevarj!trevarj@irc.gitter.im"]Should be like this I think :
params["trevarj", "Gitter trevarj!trevarj@irc.gitter.im"]Edit: @osa1 I think it’s because this is the full message that the server sends:
:irc.gitter.im 001 trevarj Gitter :trevarj!trevarj@irc.gitter.imand thenparse_paramsinlibtiny_wire::lib.rsis splitting on that second colon.To me it seems like this is the server’s fault? They should be sending the message like
:irc.gitter.im 001 trevarj :Gitter trevarj!trevarj@irc.gitter.im. In the examples of RPL_WELCOME messages it appears that this is the acceptable format.One more edit: https://gitlab.com/gitlab-org/gitter/irc-bridge/-/blob/develop/lib/gitter-adapter.js#L271