smartnode / telebot

Telegram Bot API in C
https://elmurod.net/telebot
Apache License 2.0
162 stars 38 forks source link

User editing already send message will result in crash. #30

Closed Nik4053 closed 4 years ago

Nik4053 commented 4 years ago

If the user presses the arrow up key in Telegram to access his last written message and then edits that message the echobot will crash with Segmentation Fault in line 66. message.from, message.text and message.chat are all NULL

smartnode commented 4 years ago

I can't test this at the moment. Can you provide backtrace with gdb?

Nik4053 commented 4 years ago

Here the backtrace. (I removed the token and str value because I do not know what they contain and I would like my telegram token not to be open in public.)

#0  0x0000000008000fe9 in main (argc=1, argv=0x7ffffffedfc8)
    at /home/echobot.c:66
        updates = 0x8477af0
        fp = 0x8420510
        token = "###########"...
        handle = 0x8406ed0
        me = 0x84345d0
        index = 0
        count = 1
        offset = 1
        str = "##########"...
        ret = TELEBOT_ERROR_NONE
        message = {message_id = 0, from = 0x0, date = 0, chat = 0x0, forward_from = 0x0, forward_date = 0,
          reply_to_message = 0x0, edit_date = 0, media_group_id = 0x0, author_signature = 0x0, text = 0x0,
          entities = 0x0, count_entities = 0, caption_entities = 0x0, count_caption_entities = 0, audio = 0x0,
          document = 0x0, game = 0x0, photos = 0x0, count_photos = 0, sticker = 0x0, video = 0x0, animation = 0x0,
          voice = 0x0, video_note = 0x0, caption = 0x0, contact = 0x0, location = 0x0, venue = 0x0,
          new_chat_members = 0x0, count_new_chat_members = 0, left_chat_members = 0x0, count_left_chat_members = 0,
          new_chat_title = 0x0, new_chat_photos = 0x0, count_new_chat_photos = 0, delete_chat_photo = false,
smartnode commented 4 years ago

This happened due to not checking update_type. It has been fixed in the latest commit.