smartnode/telebot

Telebot crashes if user send less then 3 characters.

Closed this issue · 2 comments

I have played around with echobot.c and found that it crashes if I send 2 letters. No problems if I send 3 or more letters. Got errors:
[DEBUG][telebot_core_curl_perform:142]Response: {"ok":true,"result":[{"update_id":345541365, "message":{"message_id":86,"from":{"id":337925211,"is_bot":false,"first_name":"Loosing","last_name":"Control","username":"Cartoonboy","language_code":"en"},"chat":{"id":337925211,"first_name":"Loosing","last_name":"Control","username":"Cartoonboy","type":"private"},"date":1594114626,"text":"du"}}]} corrupted size vs. prev_size Aborted (core dumped)
or

[DEBUG][telebot_core_curl_perform:142]Response: {"ok":true,"result":[{"update_id":345541357, "message":{"message_id":76,"from":{"id":337925211,"is_bot":false,"first_name":"Loosing","last_name":"Control","username":"Cartoonboy","language_code":"en"},"chat":{"id":337925211,"first_name":"Loosing","last_name":"Control","username":"Cartoonboy","type":"private"},"date":1594113760,"text":"ll"}}]} malloc(): invalid next size (unsorted) Aborted (core dumped)

The only change I made in echobot.c was function "telebot_send_dice(....)" which can be called by "/dice".
So, if I send bot "du" or other two characters it crashes and to make bot work properly again i need to call "/dice" command and start bot again, otherwise it crashes receiving last command "du".

And I'm lack of inline keyboard))))) I saw in doc's that it is in TODO mood, and I hope you will do it in recent future. Yep, I am that one strange guy who wants to write bot using C in 2020)))))

P.S. it also crashes if user sends emoji or sticker

Please test my pull request (#39), it should fix first crash (corrupted size etc.)

ozbek commented

I second that #39 fixes this.