GithubHelp home page GithubHelp logo

tgl's Introduction

This is library that handles telegram api and protocol.

Current versions:

  • scheme.tl: Layer 38
  • encrypted_scheme.tl: Layer 23

API, Protocol documentation

Documentation for Telegram API is available here: https://core.telegram.org/api

Documentation for MTproto protocol is available here: https://core.telegram.org/mtproto

Installation

Clone GitHub Repository

 git clone --recursive  https://github.com/vysheng/tgl.git && cd tgl

Linux and BSDs

Install libs: openssl, zlib if you want to use provided net/timers then install libevent and add --enable-libevent key to configure

You can also avoid the OpenSSL dependency: Install gcrypt (>= 1.60, Debian derivates know it as "libgcrypt20-dev"), and add --disable-openssl key to configure

Then,

 ./configure
 make

Contacts

If you would like to ask a question, you can write to my telegram or to the github (or both). To contact me via telegram, you should use import_card method with argument 000653bf:0738ca5d:5521fbac:29246815:a27d0cda

tgl's People

Contributors

benwiederhake avatar eionrobb avatar gokceneraslan avatar hedayat avatar lkraider avatar majn avatar schroedingerszombie avatar vysheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tgl's Issues

ERROR: auth_key_id should be NULL

I followed every step to make it work. I'm using Commit 76824c2 on Ubuntu 14.04.2 LTS.

After the command

./telegram-cli -k tg-server.pub -c telegram.config

I get

/usr/src/tg/zabbix# ./telegram-cli -k tg-server.pub -c telegram.config
change_user_group: can't find the user telegramd to switch to
Telegram-cli version 1.2.0, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type show_license'. This is free software, and you are welcome to redistribute it under certain conditions; typeshow_license' for details.
Telegram-cli uses libtgl version 1.2.0
No binlog found. Creating new one
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
*** ERROR: auth_key_id should be NULL
telegram-cli: tgl/mtproto-client.c:1247: tc_becomes_ready: Assertion `0' failed.
SIGNAL received

Having telegram.config edited like:

default_profile = "zabbix";

 zabbix = {
    config_directory = "/usr/src/tg/zabbix/";
    test = false;
    #msg_num = true;
    binlog_enabled = true;
    log_level = 2;
}; 

I'm able to type my cell phone, but then I receive a SMS on it saying:

You are using an outdated app that doesn't support 2-step verification. Please update your app to log in to Telegram.

Get all messages not unknown to the current client

In an old state of telegram-cli, do_get_difference() would fetch all messages unknown to the current client. In libtgl the function would just return any messages unread on any client, so if you've already read a message on your phone app you would not receive it with libtgl anymore.

I don't know whether this is due to changes in your code, or changes in the Telegram API, but is it somehow possible to get back the old behavior?

secret chat and visualize_key issues in 1.3.3

I send out telegram messages with telegram-cli -W -e 'msg !_<userid> text' (1.3.3, CentOS RPM) to secret chats which are read an the latest Android telegram app.

  1. Only recently since a few days it repeatedly occured that the secret chat was shown as "terminated". I'm not sure if this is an issue in telegram-cli or Telegram (Android) or possibly even in MPROTO?
  2. Anyway, the command visualize_key seems to be broken. The first time after initiating a new secret chat it works, but after closing the telegram-cli session and restarting telegram-cli, visualize_key only shows an entirely grey box instead of the key. The secret chat itself however works so I assume this is a telegram-cli problem and could also be related to the first obseration.

Compiler pointer warnings

I am building the library on a 64bit architecture where intptr_t and size_t are long and there are tons of warnings because of the int pointer arithmetic used throughout the lib.

Do you think it would be safe to replace all pointers with intptr_t and size_t where the warnings happen? Or is somehow the use of int guaranteed to be safe in your implementation of pointer arithmetic so the warnings can be ignored?

Assertion `C->user_list[i].user_id != user' failed

Sometimes cli stops working because of this below error. Help me please if anybody faced with this. Vysheng can you advise anything?

telegram-cli: tgl/binlog.c:723: fetch_comb_binlog_chat_add_participant: Assertion `C->user_list[i].user_id != user' failed.
SIGNAL received
h./bin/telegram-cli(print_backtrace+0x20)[0x4437d0]
./bin/telegram-cli(termination_signal_handler+0x64)[0x443854]
/lib/x86_64-linux-gnu/libc.so.6(+0x36c30)[0x7f9815fabc30]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x39)[0x7f9815fabbb9]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x148)[0x7f9815faefc8]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fa76)[0x7f9815fa4a76]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fb22)[0x7f9815fa4b22]
./bin/telegram-cli[0x479208]
./bin/telegram-cli[0x4797f8]
./bin/telegram-cli(tglu_work_update+0x821)[0x47e321]
./bin/telegram-cli(tglu_work_updates+0xeb)[0x47fb8b]
./bin/telegram-cli[0x4562bd]
./bin/telegram-cli[0x4563b7]
./bin/telegram-cli[0x457572]
./bin/telegram-cli[0x48129b]
/usr/lib/x86_64-linux-gnu/libevent-2.0.so.5(event_base_loop+0x754)[0x7f9816fbef24]
./bin/telegram-cli(net_loop+0xa4)[0x444914]
./bin/telegram-cli(loop+0x16e)[0x445c0e]
./bin/telegram-cli(main+0x286)[0x442306]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f9815f96ec5]
./bin/telegram-cli[0x4423ee]

Failure and shutdown after sending a message

After sending a message from telegram cli I get an error message:

telegram-cli: tgl/structures.c:2035: tglm_message_insert_tree: Assertion `M->id' failed.
SIGNAL received

Telegram then shuts down. It seems that the failure appears, when message is marked_read at the receiver

Proble with installation on El Capitan

I'm trying to compile this library on my mac

git clone --recursive https://github.com/vysheng/tgl.git
cd tgl
./configure --with-openssl=/usr/local/Cellar/openssl/1.0.2g

checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for sqrt in -lm... yes
checking for library containing clock_gettime... no
checking for openssl/ssl.h in /usr/local/Cellar/openssl/1.0.2g... yes
checking whether compiling and linking against OpenSSL works... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking if zlib is wanted... yes
checking for inflateEnd in -lz... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking execinfo.h usability... yes
checking execinfo.h presence... yes
checking for execinfo.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking malloc.h usability... no
checking malloc.h presence... no
checking for malloc.h... no
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking mach/mach.h usability... yes
checking mach/mach.h presence... yes
checking for mach/mach.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for size_t... yes
checking for uid_t in sys/types.h... yes
checking for inline... inline
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible realloc... yes
checking for alarm... yes
checking for endpwent... yes
checking for memset... yes
checking for memmove... yes
checking for mkdir... yes
checking for select... yes
checking for socket... yes
checking for strdup... yes
checking for strndup... yes
checking for uname... yes
checking for __builtin_bswap32... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
make

cat scheme.tl encrypted_scheme.tl binlog.tl mtproto.tl append.tl > auto/scheme.tl
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tl-parser -c -MP -MD -MF dep/tl-parser.d -MQ objs/tl-parser.o -o objs/tl-parser.o tl-parser/tl-parser.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tl-parser -c -MP -MD -MF dep/tlc.d -MQ objs/tlc.o -o objs/tlc.o tl-parser/tlc.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tl-parser -c -MP -MD -MF dep/crc32.d -MQ objs/crc32.o -o objs/crc32.o tl-parser/crc32.c
gcc objs/tl-parser.o objs/tlc.o objs/crc32.o -L/usr/local/lib -L/usr/lib -L/usr/lib -L/usr/local/Cellar/openssl/1.0.2g/lib -rdynamic -ggdb -lz -lm   -lssl -lcrypto -o bin/tl-parser
bin/tl-parser -E auto/scheme.tl 2> auto/scheme2.tl  || ( cat auto/scheme2.tl && rm auto/scheme2.tl && false )
awk -f ./gen_constants_h.awk < auto/scheme2.tl > auto/constants.h
bin/tl-parser -e auto/scheme.tlo auto/scheme.tl
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/generate.d -MQ objs/generate.o -o objs/generate.o generate.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/tools.d -MQ objs/tools.o -o objs/tools.o tools.c
gcc objs/generate.o objs/tools.o -L/usr/local/lib -L/usr/lib -L/usr/lib -L/usr/local/Cellar/openssl/1.0.2g/lib -rdynamic -ggdb -lz -lm   -lssl -lcrypto -o bin/generate
bin/generate -g skip-header auto/scheme.tlo > auto/auto-skip.h || rm auto/auto-skip.h
bin/generate -g fetch-header auto/scheme.tlo > auto/auto-fetch.h || rm auto/auto-fetch.h
bin/generate -g store-header auto/scheme.tlo > auto/auto-store.h || rm auto/auto-store.h
bin/generate -g autocomplete-header auto/scheme.tlo > auto/auto-autocomplete.h || rm auto/auto-autocomplete.h
bin/generate -g types-header auto/scheme.tlo > auto/auto-types.h || rm auto/auto-types.h
bin/generate -g fetch-ds-header auto/scheme.tlo > auto/auto-fetch-ds.h || rm auto/auto-fetch-ds.h
bin/generate -g free-ds-header auto/scheme.tlo > auto/auto-free-ds.h || rm auto/auto-free-ds.h
bin/generate -g store-ds-header auto/scheme.tlo > auto/auto-store-ds.h || rm auto/auto-store-ds.h
bin/generate -g print-ds-header auto/scheme.tlo > auto/auto-print-ds.h || rm auto/auto-print-ds.h
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/mtproto-common.d -MQ objs/mtproto-common.o -o objs/mtproto-common.o mtproto-common.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/mtproto-client.d -MQ objs/mtproto-client.o -o objs/mtproto-client.o mtproto-client.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/queries.d -MQ objs/queries.o -o objs/queries.o queries.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/structures.d -MQ objs/structures.o -o objs/structures.o structures.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/binlog.d -MQ objs/binlog.o -o objs/binlog.o binlog.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/tgl.d -MQ objs/tgl.o -o objs/tgl.o tgl.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/updates.d -MQ objs/updates.o -o objs/updates.o updates.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/tg-mime-types.d -MQ objs/tg-mime-types.o -o objs/tg-mime-types.o tg-mime-types.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF dep/mtproto-utils.d -MQ objs/mtproto-utils.o -o objs/mtproto-utils.o mtproto-utils.c
bin/generate -g skip auto/scheme.tlo > auto/auto-skip.c || rm auto/auto-skip.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-skip.d -MQ objs/auto-skip.o -o objs/auto/auto-skip.o auto/auto-skip.c
bin/generate -g fetch auto/scheme.tlo > auto/auto-fetch.c || rm auto/auto-fetch.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-fetch.d -MQ objs/auto-fetch.o -o objs/auto/auto-fetch.o auto/auto-fetch.c
bin/generate -g store auto/scheme.tlo > auto/auto-store.c || rm auto/auto-store.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-store.d -MQ objs/auto-store.o -o objs/auto/auto-store.o auto/auto-store.c
bin/generate -g autocomplete auto/scheme.tlo > auto/auto-autocomplete.c || rm auto/auto-autocomplete.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-autocomplete.d -MQ objs/auto-autocomplete.o -o objs/auto/auto-autocomplete.o auto/auto-autocomplete.c
bin/generate -g types auto/scheme.tlo > auto/auto-types.c || rm auto/auto-types.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-types.d -MQ objs/auto-types.o -o objs/auto/auto-types.o auto/auto-types.c
bin/generate -g fetch-ds auto/scheme.tlo > auto/auto-fetch-ds.c || rm auto/auto-fetch-ds.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-fetch-ds.d -MQ objs/auto-fetch-ds.o -o objs/auto/auto-fetch-ds.o auto/auto-fetch-ds.c
bin/generate -g free-ds auto/scheme.tlo > auto/auto-free-ds.c || rm auto/auto-free-ds.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-free-ds.d -MQ objs/auto-free-ds.o -o objs/auto/auto-free-ds.o auto/auto-free-ds.c
bin/generate -g store-ds auto/scheme.tlo > auto/auto-store-ds.c || rm auto/auto-store-ds.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-store-ds.d -MQ objs/auto-store-ds.o -o objs/auto/auto-store-ds.o auto/auto-store-ds.c
bin/generate -g print-ds auto/scheme.tlo > auto/auto-print-ds.c || rm auto/auto-print-ds.c
gcc -I. -I. -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/local/Cellar/openssl/1.0.2g/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto-print-ds.d -MQ objs/auto-print-ds.o -o objs/auto/auto-print-ds.o auto/auto-print-ds.c
rm -f libs/libtgl.a && ar ruv libs/libtgl.a objs/mtproto-common.o objs/mtproto-client.o objs/queries.o objs/structures.o objs/binlog.o objs/tgl.o objs/updates.o objs/tg-mime-types.o objs/mtproto-utils.o  objs/tools.o
ar: creating archive libs/libtgl.a
a - objs/mtproto-common.o
a - objs/mtproto-client.o
a - objs/queries.o
a - objs/structures.o
a - objs/binlog.o
a - objs/tgl.o
a - objs/updates.o
a - objs/tg-mime-types.o
a - objs/mtproto-utils.o
a - objs/tools.o
gcc -shared -o libs/libtgl.so objs/mtproto-common.o objs/mtproto-client.o objs/queries.o objs/structures.o objs/binlog.o objs/tgl.o objs/updates.o objs/tg-mime-types.o objs/mtproto-utils.o  objs/tools.o -L/usr/local/lib -L/usr/lib -L/usr/lib -L/usr/local/Cellar/openssl/1.0.2g/lib -rdynamic -ggdb -lz -lm   -lssl -lcrypto
Undefined symbols for architecture x86_64:
  "_fetch_ds_type_any", referenced from:
      _tglq_query_result in queries.o
  "_fetch_ds_type_binlog_update", referenced from:
      _replay_log_event in binlog.o
  "_fetch_ds_type_decrypted_message_layer", referenced from:
      _tglf_fetch_encrypted_message_new in structures.o
  "_fetch_ds_type_decrypted_message_media", referenced from:
      _send_part in queries.o
  "_fetch_ds_type_send_message_action", referenced from:
      _tglf_fetch_typing in structures.o
  "_fetch_ds_type_updates", referenced from:
      _tglu_work_any_updates in updates.o
  "_free_ds_type_any", referenced from:
      _tglq_query_result in queries.o
  "_free_ds_type_binlog_update", referenced from:
      _replay_log_event in binlog.o
  "_free_ds_type_decrypted_message_layer", referenced from:
      _tglf_fetch_encrypted_message_new in structures.o
  "_free_ds_type_decrypted_message_media", referenced from:
      _send_part in queries.o
  "_free_ds_type_send_message_action", referenced from:
      _tglf_fetch_typing in structures.o
  "_free_ds_type_update", referenced from:
      _msg_send_on_answer in queries.o
  "_free_ds_type_updates", referenced from:
      _tglu_work_any_updates in updates.o
  "_skip_type_any", referenced from:
      _process_respq_answer in mtproto-client.o
      _process_dh_answer in mtproto-client.o
      _process_auth_complete in mtproto-client.o
      _tglq_query_result in queries.o
      _send_part in queries.o
      _replay_log_event in binlog.o
  "_skip_type_decrypted_message_layer", referenced from:
      _tglf_fetch_encrypted_message_new in structures.o
  "_store_ds_type_bot_info", referenced from:
      _bl_do_user_new in binlog.o
  "_store_ds_type_chat_photo", referenced from:
      _bl_do_chat_new in binlog.o
  "_store_ds_type_decrypted_message_action", referenced from:
      _bl_do_create_message_encr_new in binlog.o
  "_store_ds_type_decrypted_message_media", referenced from:
      _bl_do_create_message_encr_new in binlog.o
  "_store_ds_type_encrypted_file", referenced from:
      _bl_do_create_message_encr_new in binlog.o
  "_store_ds_type_message_action", referenced from:
      _bl_do_create_message_new in binlog.o
  "_store_ds_type_message_media", referenced from:
      _bl_do_create_message_new in binlog.o
  "_store_ds_type_photo", referenced from:
      _bl_do_user_new in binlog.o
      _bl_do_chat_new in binlog.o
  "_store_ds_type_reply_markup", referenced from:
      _bl_do_create_message_new in binlog.o
  "_store_ds_type_user_profile_photo", referenced from:
      _bl_do_user_new in binlog.o
  "_store_ds_type_vector", referenced from:
      _bl_do_chat_new in binlog.o
  "_tgl_paramed_type_free", referenced from:
      _ext_query_on_answer in queries.o
  "_tglf_extf_print_ds", referenced from:
      _ext_query_on_answer in queries.o
  "_tglf_extf_store", referenced from:
      _tgl_do_send_extf in queries.o
  "_tl_type_account_password", referenced from:
      _.compoundliteral214 in queries.o
      _.compoundliteral216 in queries.o
  "_tl_type_auth_authorization", referenced from:
      _.compoundliteral136 in queries.o
      _.compoundliteral180 in queries.o
      _.compoundliteral220 in queries.o
  "_tl_type_auth_exported_authorization", referenced from:
      _.compoundliteral179 in queries.o
  "_tl_type_auth_sent_code", referenced from:
      _.compoundliteral132 in queries.o
  "_tl_type_bare_int", referenced from:
      _.compoundliteral193 in queries.o
  "_tl_type_binlog_update", referenced from:
      _replay_log_event in binlog.o
  "_tl_type_bool", referenced from:
      _.compoundliteral119 in queries.o
      _.compoundliteral135 in queries.o
      _.compoundliteral154 in queries.o
      _.compoundliteral198 in queries.o
      _.compoundliteral207 in queries.o
      _.compoundliteral222 in queries.o
      _.compoundliteral223 in queries.o
      ...
  "_tl_type_bot_info", referenced from:
      _bl_do_user_new in binlog.o
  "_tl_type_chat_participant", referenced from:
      _bl_do_chat_new in binlog.o
  "_tl_type_chat_photo", referenced from:
      _bl_do_chat_new in binlog.o
  "_tl_type_config", referenced from:
      _.compoundliteral130 in queries.o
  "_tl_type_contacts_contacts", referenced from:
      _.compoundliteral137 in queries.o
  "_tl_type_contacts_imported_contacts", referenced from:
      _.compoundliteral182 in queries.o
  "_tl_type_contacts_link", referenced from:
      _.compoundliteral185 in queries.o
  "_tl_type_decrypted_message_action", referenced from:
      _bl_do_create_message_encr_new in binlog.o
  "_tl_type_decrypted_message_layer", referenced from:
      _tglf_fetch_encrypted_message_new in structures.o
  "_tl_type_decrypted_message_media", referenced from:
      _send_part in queries.o
      _bl_do_create_message_encr_new in binlog.o
  "_tl_type_encrypted_chat", referenced from:
      _.compoundliteral123 in queries.o
      _.compoundliteral124 in queries.o
  "_tl_type_encrypted_file", referenced from:
      _bl_do_create_message_encr_new in binlog.o
  "_tl_type_exported_chat_invite", referenced from:
      _.compoundliteral202 in queries.o
  "_tl_type_message_action", referenced from:
      _bl_do_create_message_new in binlog.o
  "_tl_type_message_media", referenced from:
      _bl_do_create_message_new in binlog.o
  "_tl_type_messages_affected_history", referenced from:
      _.compoundliteral141 in queries.o
  "_tl_type_messages_affected_messages", referenced from:
      _.compoundliteral192 in queries.o
  "_tl_type_messages_chat_full", referenced from:
      _.compoundliteral167 in queries.o
  "_tl_type_messages_dh_config", referenced from:
      _.compoundliteral126 in queries.o
  "_tl_type_messages_dialogs", referenced from:
      _.compoundliteral146 in queries.o
  "_tl_type_messages_messages", referenced from:
      _.compoundliteral143 in queries.o
      _.compoundliteral186 in queries.o
      _.compoundliteral199 in queries.o
  "_tl_type_messages_sent_encrypted_message", referenced from:
      _.compoundliteral in queries.o
      _.compoundliteral163 in queries.o
  "_tl_type_messages_sent_message", referenced from:
      _.compoundliteral138 in queries.o
  "_tl_type_photo", referenced from:
      _bl_do_user_new in binlog.o
      _bl_do_chat_new in binlog.o
  "_tl_type_photos_photo", referenced from:
      _.compoundliteral160 in queries.o
  "_tl_type_reply_markup", referenced from:
      _bl_do_create_message_new in binlog.o
  "_tl_type_res_p_q", referenced from:
      _process_respq_answer in mtproto-client.o
  "_tl_type_send_message_action", referenced from:
      _tglf_fetch_typing in structures.o
  "_tl_type_server_d_h_inner_data", referenced from:
      _process_dh_answer in mtproto-client.o
  "_tl_type_server_d_h_params", referenced from:
      _process_dh_answer in mtproto-client.o
  "_tl_type_set_client_d_h_params_answer", referenced from:
      _process_auth_complete in mtproto-client.o
  "_tl_type_update", referenced from:
      _msg_send_on_answer in queries.o
  "_tl_type_updates", referenced from:
      _.compoundliteral166 in queries.o
      _tglu_work_any_updates in updates.o
  "_tl_type_updates_difference", referenced from:
      _.compoundliteral188 in queries.o
  "_tl_type_updates_state", referenced from:
      _.compoundliteral187 in queries.o
      _.compoundliteral191 in queries.o
  "_tl_type_upload_file", referenced from:
      _.compoundliteral174 in queries.o
  "_tl_type_user", referenced from:
      _.compoundliteral164 in queries.o
      _.compoundliteral165 in queries.o
      _.compoundliteral197 in queries.o
  "_tl_type_user_full", referenced from:
      _.compoundliteral168 in queries.o
  "_tl_type_user_profile_photo", referenced from:
      _bl_do_user_new in binlog.o
  "_tl_type_vector", referenced from:
      _.compoundliteral195 in queries.o
      _bl_do_chat_new in binlog.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libs/libtgl.so] Error 1

tgl_peer_get returns NULL

Sometimes, shortly after launch, usually when someone messages the current user, calling tgl_peer_get() on M.to_id returns NULL.

Command line msg command with secure chats

Hi send out messages to secure chats from command line via:

telegram-cli -W -e msg '!_user@123456 myMessage' -D

However, since 1.3.3, this doesn't work anymore. Output of this command is the same as with previous versions, but no message arrives.

> All done. Exit
halt

It seems to be the quotation is not understand anymore, so I did: telegram-cli -W -e msg !_user@123456 myMessage -D – but bash doesn't like the exclamation mark and escaping it didn't help.

Can you help me with correctly calling this command? It would help if secure chats wouldn't have an exclamation mark in the user/chat name. Is there any other solution? Thanks.

channels support

Are you planning it? I mean both creating new channels and sending messages

Hardening PRNG

I noticed that tgl_prng_seed is adding Time, PID and 32bytes of random data. It would be best to seed all of the PRNG from random bytes (from each operating systems PRNG system) instead. We could then remove the 2 unused arguments since they are defines to "password" files (currently set to NULL through defines).

If there are no objections, I can work on a patch in my own tree and submit a pull request once it is complete.

Nullpointer dereference when freeing message media after fetching complete history

How to reproduce

  1. Call tgl_do_get_difference and set the flag to sync from start.
  2. Load every single received message photo
  3. Call tgl_free_all()

This will cause a nullpointer dereference in libtgl:

    (lldb) bt
    thread #1: tid = 0x440cf0, 0x000000010e127dbb telegram-adium`tgls_free_photo(TLS=0x0000000102804200, P=0x0000000000000000) + 27 at structures.c:1702, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x000000010e127dbb telegram-adium`tgls_free_photo(TLS=0x0000000102804200, P=0x0000000000000000) + 27 at structures.c:1702
    frame #1: 0x000000010e1283be telegram-adium`tgls_free_message_media(TLS=<unavailable>, M=0x0000608001530e64) + 78 at structures.c:1757
    frame #2: 0x000000010e12889d telegram-adium`tgls_free_message [inlined] tgls_clear_message(M=<unavailable>) + 77 at structures.c:1841
    frame #3: 0x000000010e128860 telegram-adium`tgls_free_message(TLS=<unavailable>, M=0x0000608001530e00) + 16 at structures.c:1858
    frame #4: 0x000000010e129428 telegram-adium`tree_act_ex_message(T=0x0000608001035040, act=0x000000010e129e30, extra=0x0000000102804200) + 56 at structures.c:85
    frame #5: 0x000000010e12941e telegram-adium`tree_act_ex_message(T=0x00006080010350c0, act=0x000000010e129e30, extra=0x0000000102804200) + 46 at structures.c:85
    frame #6: 0x000000010e12941e telegram-adium`tree_act_ex_message(T=0x0000608001035120, act=0x000000010e129e30, extra=0x0000000102804200) + 46 at structures.c:85
    frame #7: 0x000000010e12941e telegram-adium`tree_act_ex_message(T=0x0000608001035260, act=0x000000010e129e30, extra=0x0000000102804200) + 46 at structures.c:85
    frame #8: 0x000000010e12941e telegram-adium`tree_act_ex_message(T=0x00006080010354e0, act=0x000000010e129e30, extra=0x0000000102804200) + 46 at structures.c:85
    frame #9: 0x000000010e12941e telegram-adium`tree_act_ex_message(T=0x00006080010355c0, act=0x000000010e129e30, extra=0x0000000102804200) + 46 at structures.c:85
    frame #10: 0x000000010e12941e telegram-adium`tree_act_ex_message(T=0x000060800043be00, act=0x000000010e129e30, extra=0x0000000102804200) + 46 at structures.c:85
    frame #11: 0x000000010e12941e telegram-adium`tree_act_ex_message(T=0x0000608001239a80, act=0x000000010e129e30, extra=0x0000000102804200) + 46 at structures.c:85
    frame #12: 0x000000010e129ebe telegram-adium`tgl_free_all(TLS=0x0000000102804200) + 110 at structures.c:2202
    frame #13: 0x000000010e10a53e telegram-adium`connection_data_free(conn=0x00006080002c02a0) + 222 at tgp-structs.c:118
    frame #14: 0x000000010e0ee303 telegram-adium`tgprpl_close(gc=0x00006080002a0f00) + 51 at telegram-purple.c:609
    frame #15: 0x00000001007fbda6 libpurple`_purple_connection_destroy + 240
    frame #16: 0x00000001007e9cb2 libpurple`purple_account_disconnect + 168
    frame #17: 0x000000010041bee4 AdiumLibpurple`-[CBPurpleAccount disconnect] + 146
    frame #18: 0x000000010041c777 AdiumLibpurple`-[CBPurpleAccount updateStatusForKey:] + 50
    frame #19: 0x000000010041eefe AdiumLibpurple`-[CBPurpleAccount preferencesChangedForGroup:key:object:preferenceDict:firstTime:] + 94
    frame #20: 0x00000001000f3d00 Adium`___lldb_unnamed_function3759$$Adium + 394
    frame #21: 0x000000010011993d Adium`___lldb_unnamed_function4361$$Adium + 308
    frame #22: 0x00000001004db187 Adium`-[AIAccount(Abstract) setShouldBeOnline:] + 70
    frame #23: 0x00000001000ecda8 Adium`___lldb_unnamed_function3671$$Adium + 706
    frame #24: 0x00007fff8df6a7bc CoreFoundation`__invoking___ + 140
    frame #25: 0x00007fff8df6a612 CoreFoundation`-[NSInvocation invoke] + 290
    frame #26: 0x00007fff8e00a5c6 CoreFoundation`-[NSInvocation invokeWithTarget:] + 54
    frame #27: 0x00007fff983d04eb Foundation`__NSFireDelayedPerform + 364
    frame #28: 0x00007fff8dfe62e4 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    frame #29: 0x00007fff8dfe5f73 CoreFoundation`__CFRunLoopDoTimer + 1059
    frame #30: 0x00007fff8e05953d CoreFoundation`__CFRunLoopDoTimers + 301
    frame #31: 0x00007fff8dfa1608 CoreFoundation`__CFRunLoopRun + 2024
    frame #32: 0x00007fff8dfa0bd8 CoreFoundation`CFRunLoopRunSpecific + 296
    frame #33: 0x00007fff8a7aa56f HIToolbox`RunCurrentEventLoopInMode + 235
    frame #34: 0x00007fff8a7aa1ee HIToolbox`ReceiveNextEventCommon + 179
    frame #35: 0x00007fff8a7aa12b HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
    frame #36: 0x00007fff8c9048ab AppKit`_DPSNextEvent + 978
    frame #37: 0x00007fff8c903e58 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
    frame #38: 0x00007fff8c8f9af3 AppKit`-[NSApplication run] + 594
    frame #39: 0x00007fff8c876244 AppKit`NSApplicationMain + 1832
    frame #40: 0x0000000100002584 Adium`___lldb_unnamed_function1$$Adium + 52

Using libtgl in my project on commit majn/telegram-purple@1004a40 , the libtgl version is my own modified branch including my recent pull request majn@126b42c , although the changes don't seem to affect this issues.

Support API layer 51

Otherwise messages with inline keyboards will be unreachable ([unsupported]).

Is memcmp of struct query incorrect?

In https://github.com/vysheng/tgl/blob/master/queries.c#L105-L106 the code says

#define memcmp8(a,b) memcmp ((a), (b), 8)
DEFINE_TREE (query, struct query *, memcmp8, 0) ;

To say that a struct query is unique based on the first 8 bytes (64 bits) of the struct, however struct query is defined at https://github.com/vysheng/tgl/blob/master/queries.h#L38 to be

struct query {
  long long msg_id;
  int data_len;
  int flags;
...

Is the intention to compare msg_id's for uniqueness? because long long is not guaranteed to be exactly 64-bit, only 'at least' 64-bit in size.

Should this code instead be changed to something like

static int cmp_query(struct query *a, struct query *b) { return (a->msg_id - b->msg_id); }
DEFINE_TREE (query, struct query *, cmp_query, 0) ;

and could this be what is causing crashes in majn/telegram-purple#220

Sending documents bricks secret chats

Sending a document /photos to a secret chat will render the chat unusable. You can still send messages, but you cannot receive messages any longer. I believe that this is an issue with libtgl, as it happens both in telegram-purple and telegram-cli.

Reproduce in telegram-cli:

create_secret_chat PEER
send_photo SECRET CHAT PEER /Users/matj/Desktop/photo.png

From this point on, it is only possible to receive messages, but all sending message won't be displayed for the other client any longer.

Crash when network failure while sending a message

Steps to reproduce:

  • Disconnect the machine in a way so that no component knows what happened. (In virtualbox: fiddle with the network settings, but make sure that the OS doesn't notice that something changed)
  • try to send a message

Expected behavior: Not a crash

Actual behavior and gdb backtrace:

*** Error in `/usr/bin/pidgin': double free or corruption (!prev): 0x000055555677d4f0 ***

Program received signal SIGABRT, Aborted.
0x00007ffff449acc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: Datei oder Verzeichnis nicht gefunden.
(gdb) bt full
#0  0x00007ffff449acc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
[SNIP]
#1  0x00007ffff449e0d8 in __GI_abort () at abort.c:89
[SNIP]
#2  0x00007ffff44d7394 in __libc_message (do_abort=do_abort@entry=1,
[SNIP]
#3  0x00007ffff44e366e in malloc_printerr (ptr=<optimized out>, str=0x7ffff45e5c10 "double free or
[SNIP]
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
[SNIP]
#5  0x00007fffd5deede8 in tree_act_ex_message (T=<optimized out>, act=act@entry=0x7fffd5df29e0 <tgls_free_message_gw>, 
    extra=extra@entry=0x5555565d0c50) at structures.c:84
No locals.
#6  0x00007fffd5df670e in tgl_free_all (TLS=0x5555565d0c50) at structures.c:2471
        i = <optimized out>
#7  0x00007fffd5dd225f in connection_data_free (conn=0x555556516250) at tgp-structs.c:125
No locals.
#8  0x00007ffff4da6446 in _purple_connection_destroy () from /usr/lib/libpurple.so.0
No symbol table info available.

Thus, structures.c:2471 tries to do free a message in TLS->message_unsent_tree that already was freed.

Note that this bug was discovered in majn@bec66c2 , but there have been no changes to TLS->message_unsent_tree since then.

Copy message from other channel

Hi
Sorry,I have a question about your project(telegram).
Can I get the message channels that I'm not their admin?
I want write a script that read message from other chanel and write to
my chanel.
I can do it?
best regards
thanks

Sending messages during update events not possible.

Sending messages will call add_log_event for the second time, while it is already called when the update callback is exected. This will alter the global rptr and wptrs and fail an assertion once the execution returns to the first add_log_event call.

This can be especially hurtful when you try to create automatic responses or chat bots.

bildschirmfoto 2015-04-02 um 21 08 30

Here is a stacktrace of the crash:

Assertion failed: (rptr == wptr), function add_log_event, file binlog.c, line 1589.
(lldb) bt
* thread #1: tid = 0x68faf2, 0x00007fff85abf286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff85abf286 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff87a9e42f libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fff8ce01b53 libsystem_c.dylib`abort + 129
    frame #3: 0x00007fff8cdc9c39 libsystem_c.dylib`__assert_rtn + 321
  * frame #4: 0x000000010aa546d3 telegram-adium`add_log_event(TLS=0x000000010391d400, data=0x000000010ada0b50, len=12) + 435 at binlog.c:1589
    frame #5: 0x000000010aa579ab telegram-adium`bl_do_msg_update(TLS=0x000000010391d400, id=1141) + 91 at binlog.c:2345
    frame #6: 0x000000010aa40c15 telegram-adium`get_difference_on_answer(TLS=0x000000010391d400, q=0x00006080002c33a0) + 1429 at queries.c:3490
    frame #7: 0x000000010aa33c0e telegram-adium`tglq_query_result(TLS=0x000000010391d400, id=6133225873747958784) + 1038 at queries.c:400
    frame #8: 0x000000010aa2f746 telegram-adium`work_rpc_result(TLS=0x000000010391d400, c=0x00006080001484b0, msg_id=6133225874300560385) + 214 at mtproto-client.c:856
    frame #9: 0x000000010aa2efae telegram-adium`rpc_execute_answer(TLS=0x000000010391d400, c=0x00006080001484b0, msg_id=6133225874300560385) + 734 at mtproto-client.c:952
    frame #10: 0x000000010aa2ea5d telegram-adium`process_rpc_message(TLS=0x000000010391d400, c=0x00006080001484b0, enc=0x000000010b7e1e10, len=952) + 3037 at mtproto-client.c:1136
    frame #11: 0x000000010aa2c52f telegram-adium`rpc_execute(TLS=0x000000010391d400, c=0x00006080001484b0, op=-1705492338, len=952) + 911 at mtproto-client.c:1191
    frame #12: 0x000000010aa0844a telegram-adium`try_rpc_read(c=0x00006080001484b0) + 1082 at tgp-net.c:428
    frame #13: 0x000000010aa08009 telegram-adium`try_read(c=0x00006080001484b0) + 585 at tgp-net.c:474
    frame #14: 0x000000010aa077c9 telegram-adium`conn_try_read(arg=0x00006080001484b0, source=33, cond=PURPLE_INPUT_READ) + 105 at tgp-net.c:244
    frame #15: 0x00000001006ca3ba AdiumLibpurple`__adium_input_add_block_invoke + 106
    frame #16: 0x0000000102813d43 libdispatch.dylib`_dispatch_client_callout + 8
    frame #17: 0x0000000102821054 libdispatch.dylib`_dispatch_source_latch_and_call + 1239
    frame #18: 0x0000000102818348 libdispatch.dylib`_dispatch_source_invoke + 425
    frame #19: 0x0000000102822a82 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 573
    frame #20: 0x00007fff84d0cc79 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    frame #21: 0x00007fff84cc930f CoreFoundation`__CFRunLoopRun + 2159
    frame #22: 0x00007fff84cc8858 CoreFoundation`CFRunLoopRunSpecific + 296
    frame #23: 0x00007fff8b9bbaef HIToolbox`RunCurrentEventLoopInMode + 235
    frame #24: 0x00007fff8b9bb86a HIToolbox`ReceiveNextEventCommon + 431
    frame #25: 0x00007fff8b9bb6ab HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
    frame #26: 0x00007fff8908af81 AppKit`_DPSNextEvent + 964
    frame #27: 0x00007fff8908a730 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
    frame #28: 0x00007fff8907e593 AppKit`-[NSApplication run] + 594
    frame #29: 0x00007fff89069a14 AppKit`NSApplicationMain + 1832
    frame #30: 0x0000000100044a12 Adium`main + 34
    frame #31: 0x0000000100001f84 Adium`start + 52

Please provide simple example to send message

Thank for great library!
Can you provide simple example of initialization and startup of library, authorization and sending a message to contacts?

I would like to create php extension to send telegram messages.

Fix implicit declaration of __builtin_bswap32

A friend without Gihub account gave me this:

diff —git a/mtproto-utils.c b/mtproto-utils.c
index 60572b3..ce6926e 100644
-— a/mtproto-utils.c
+++ b/mtproto-utils.c
@@ -3,6 +3,15 @@
 #include "tgl.h"
 #include "tools.h"

+#if !defined(HAVE___BUILTIN_BSWAP32) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+static inline unsigned __builtin_bswap32(unsigned x) {
+  return ((x « 24) & 0xff000000 ) |
+  ((x « 8) & 0x00ff0000 ) |
+  ((x » 8) & 0x0000ff00 ) |
+  ((x » 24) & 0x000000ff );
+}
+#endif
+
 static unsigned long long gcd (unsigned long long a, unsigned long long b) {
   return b ? gcd (b, a % b) : a;
 }

Assert in mtproto-utils.c line 101

Hello,

I encountered the assert(0) in mtproto-utils.c line 101. It says "As long as nobody ever uses this code, assume it is broken."

I had to remove the assert and it worked fine. I guess it's ok to remove it?

Make not generating tl-parser code

./configure
make

Those two commands are giving an error saying that tl-parser/tl-parser.c doesn't exist despite being a dependency, which I'm guessing means that the parser code isn't being generated. Am I doing something wrong with the build?

abrupt abort via spectrum/telegram-purple on arm7l

I was spamming SpectrumIM/spectrum2#146 (sorry for that) but @BenWiederhake helped me fixing the 32 bit issue I had at first by using the dev-1.3.0 branch of telegram-purple
Afterwards I got segfaults related to libgcrypt, I then recompiled telegram-purple and libgcrypt (version 1.7.3) with debug flags and got more details. Btw. I'm using this library via telegram-purple which is used by spectrum2

coredump:

PID: 15205 (spectrum2_libpu)
           UID: 0 (root)
           GID: 0 (root)
        Signal: 6 (ABRT)
     Timestamp: Sat 2016-10-22 12:23:30 CEST (21s ago)
  Command Line: /usr/bin/spectrum2_libpurple_backend --host 127.0.0.1 --port <PORT> --service.backend_id=1 -j telegram.<XMPP_DOMAIN> /etc/spectrum2/transports/telegram.cfg
    Executable: /usr/bin/spectrum2_libpurple_backend
 Control Group: /user.slice/user-1001.slice/session-c1.scope
          Unit: session-c1.scope
         Slice: user-1001.slice
       Session: c1
     Owner UID: 1001 (martin)
       Boot ID: 07dddbf9f70a41e1a5aeb5caac926b37
    Machine ID: 5890fdfecaaa435a8e17b789ddc2ea1a
      Hostname: raspi2
      Coredump: /var/lib/systemd/coredump/core.spectrum2_libpu.0.07dddbf9f70a41e1a5aeb5caac926b37.15205.1477131810000000000000.lz4
       Message: Process 15205 (spectrum2_libpu) of user 0 dumped core.

                Stack trace of thread 15205:
                #0  0x00000000755f48d4 _gcry_mpih_submul_1 (libgcrypt.so.20)
                #1  0x00000000755ef430 _gcry_mpih_divrem (libgcrypt.so.20)
                #2  0x00000000755ec6a4 mul_mod (libgcrypt.so.20)
                #3  0x00000000755ecde8 _gcry_mpi_powm (libgcrypt.so.20)
                #4  0x000000007559a034 is_prime (libgcrypt.so.20)
                #5  0x000000007559a7b4 check_prime (libgcrypt.so.20)
                #6  0x000000007559c0cc _gcry_prime_check (libgcrypt.so.20)
                #7  0x0000000075581048 gcry_prime_check (libgcrypt.so.20)
                #8  0x00000000701afdbc TGLC_bn_is_prime (telegram-purple.so)
                #9  0x00000000701af7f8 check_prime (telegram-purple.so)
                #10 0x000000007018498c process_dh_answer (telegram-purple.so)
                #11 0x00000000701880f8 rpc_execute (telegram-purple.so)
                #12 0x00000000701757f8 try_rpc_read (telegram-purple.so)
                #13 0x0000000000052b14 _start (spectrum2_libpurple_backend)

detailed stacktrace:

(gdb) bt
#0  0x755f48d4 in _gcry_mpih_submul_1 (res_ptr=0xd78c8b64, res_ptr@entry=0x21170d4, s1_ptr=0xd78c8cf0, 
    s1_ptr@entry=0x2117260, s1_size=s1_size@entry=1969145508, s2_limb=s2_limb@entry=3278931355) at mpih-mul3.c:60
#1  0x755ef430 in _gcry_mpih_divrem (qp=qp@entry=0x2117158, qextra_limbs=2127286472, qextra_limbs@entry=0, np=0x21170d4, 
    np@entry=0x2117058, nsize=<optimized out>, dp=0x2116f50, dp@entry=0x2117260, dsize=dsize@entry=64) at mpih-div.c:366
#2  0x755ec6a4 in mul_mod (xp=xp@entry=0x2117058, xsize_p=xsize_p@entry=0x7ecbd0c8, rp=rp@entry=0x2117260, rsize=64, sp=sp@entry=0x2117260, ssize=64, mp=mp@entry=0x2116f50, msize=msize@entry=64, karactx_p=karactx_p@entry=0x7ecbd0f4) at mpi-pow.c:378
#3  0x755ecde8 in _gcry_mpi_powm (res=0x7ecbd110, res@entry=0x20a8488, base=base@entry=0x20fc198, expo=expo@entry=0xf, mod=mod@entry=0x2116178)
    at mpi-pow.c:659
#4  0x7559a034 in is_prime (n=n@entry=0x2116178, steps=steps@entry=64, count=0x7ecbd214, count@entry=0x7ecbd20c) at primegen.c:953
#5  0x7559a7b4 in check_prime (prime=prime@entry=0x2116178, val_2=0x2112018, rm_rounds=rm_rounds@entry=64, cb_func=cb_func@entry=0x0, cb_arg=cb_arg@entry=0x0) at primegen.c:891
#6  0x7559c0cc in _gcry_prime_check (x=x@entry=0x2116178, flags=flags@entry=0) at primegen.c:1179
#7  0x75581048 in gcry_prime_check (x=x@entry=0x2116178, flags=flags@entry=0) at visibility.c:1393
#8  0x701afdbc in TGLC_bn_is_prime (a=a@entry=0x2116178, checks=checks@entry=0, callback=callback@entry=
    0x0, ctx=<optimized out>, cb_arg=cb_arg@entry=0x0) at crypto/bn_altern.c:76
#9  0x701af7f8 in check_prime (TLS=0x2111898, p=0x2116178) at mtproto-utils.c:13
#10 0x701af7f8 in tglmp_check_DH_params (TLS=TLS@entry=0x2111898, p=p@entry=0x2110a78, g=g@entry=3) at mtproto-utils.c:67
#11 0x7018498c in process_dh_answer (TLS=TLS@entry=0x2111898, c=c@entry=0x21159b8, len=len@entry=652, temp_key=temp_key@entry=0, packet=0x70660d40 <Response.14104> "") at mtproto-client.c:496
#12 0x701880f8 in rpc_execute (TLS=TLS@entry=0x2111898, c=c@entry=0x21159b8, op=0, len=652) at mtproto-client.c:1171
#13 0x701757f8 in try_rpc_read (c=0x21159b8) at tgp-net.c:431
#14 0x701757f8 in try_read (c=0x21159b8) at tgp-net.c:476
#15 0x701757f8 in conn_try_read (arg=0x21159b8, source=<optimized out>, cond=<optimized out>) at tgp-net.c:227
#16 0x00052b14 in _start ()

System info:
Linux 4.4.26 on armv7l with ArchLinuxArm

I hope this is the right place to report this (or is this a libgcrypt bug?) and that anyone can guide me in the right direction. EDIT: Btw. the process segfaults if I try to register my number with Telegram, I noticed that it doesn't appear if I enter a wrong number (I get an error message regarding "phone number lacks country prefix"). I also would have spectrum logs with xmpp data if they are of use

Build failing with python 3.5

Arch Linux just updated its Python version, and I get these error when building:

gcc objs/main.o objs/loop.o objs/interface.o objs/lua-tg.o objs/json-tg.o objs/python-tg.o objs/python-types.o libs/libtgl.a -L/usr/local/lib -L/usr/lib -L/usr/lib  -rdynamic -ggdb -levent -ljansson -lconfig -lz -levent -lm   -lreadline -llua  -ldl -lpython3 -lssl -lcrypto  -ldl -lpthread -lutil -o bin/telegram-cli
/usr/bin/ld: objs/python-tg.o: undefined reference to symbol 'PyFloat_Type'
/usr/lib/libpython3.5m.so.1.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:51: recipe for target 'bin/telegram-cli' failed
make: *** [bin/telegram-cli] Error 1

Bring back message flag SESSION_OUTBOUND

I need this flag for determining if a message update is a message sent from the current device or a different one. Pidgin always prints user input right away, and I need a way to filter those messages so they don't show up twice.

See also this (working) patch I currently use on my test branch, I haven't figured out any other way to do this without changing libtgl: 31cca91

Upgrade from1.20 to 1.31

Hi,

What is the best way to upgrade from 1.20 to version 1.31.

I'm running on Ubuntu 14.04.2 LTS

When I do a fresh install I get an error

[/code]

I/usr/local/include -I/usr/include -I/usr/include - I/usr/include/lua5.2 -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-dec larations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-paramet er -fPIC -c -MP -MD -MF dep/loop.d -MQ objs/loop.o -o objs/loop.o loop.c
In file included from ./tgl/tools.h:25:0,
from ./tgl/auto.h:23,
from ./auto/auto-types.h:3,
from ./tgl/tgl-fetch.h:23,
from ./tgl/tgl-structures.h:25,
from interface.h:21,
from loop.c:56:
loop.c: In function âwrite_dcâ:
loop.c:350:35: error: âstruct tgl_dcâ has no member named âportâ
assert (write (auth_file_fd, &DC->port, 4) == 4);
^
loop.c:351:21: error: âstruct tgl_dcâ has no member named âipâ
int l = strlen (DC->ip);
^
In file included from ./tgl/tools.h:25:0,
from ./tgl/auto.h:23,
from ./auto/auto-types.h:3,
from ./tgl/tgl-fetch.h:23,
from ./tgl/tgl-structures.h:25,
from interface.h:21,
from loop.c:56:
loop.c:353:34: error: âstruct tgl_dcâ has no member named âipâ
assert (write (auth_file_fd, DC->ip, l) == l);
^
make: *** [objs/loop.o] Error 1

[/code]

Licensing - allow static linking exception

As the code is licensed under LGPL, static linking gets complicated (compared to dynamic linking).

Please consider licensing the library code with the static linking exception. An easy way could be to adopt the Mozilla License, which is compatible with LGPL and is basically the LGPL + static link exception: https://www.mozilla.org/MPL/2.0/FAQ.html.

There are some platforms where static linking is required or easier, example: iOS/Android. Having the library allow static linking could make it the go-to telegram library for those platforms.

Initially reported in tg: vysheng/tg#307

undefined refrence for static lib

tnx for this library
when i build my project(c++) to create a executable file, rais this error

libs/libtgl.a(mtproto-client.o): In function process_respq_answer': mtproto-client.c:380: undefined reference totl_type_res_p_q'
mtproto-client.c:380: undefined reference to `skip_type_any'
....

please help me to solve this issue

Escape " and ' in channel_names

hi there is a problem when we want pass somthing like this ==>
"استان البرز"شورای استانی حزب ایران بزرگ'
to history command
i mean This =>
history "استان البرز"شورای استانی حزب ایران بزرگ'
the cli itself will Escape this name with \" but its not correct !
1

and cli didnt chanded the spaces to _ as you can see in picture
it show`s up in dialog_list or channel_list but cant get the history any other command like channel_info
and i know nothing of c !
i think this happens when this characters exist in channel_name :
""
((
))
'

Getting entire history of a chat

I'm trying to get the entire history of a chat, and I was using a lua script to write to csv, but I noticed that if I try to get more than 1.5k messages (the chat has something like 500k messages), get_history doesn't return.

Going into the cli, the same thing happens. I managed to get 10k once, but anything above that has never worked for me. I'm just using the command, history [CHATNAME] 10000.

Is there an implicit limit or something? How would I go about getting the entire history of a chat?

Segfault in `generate` on Windows (test branch)

I don't really know enough about how the generate code works to be able to debug or fix this one, but hopefully the backtrace helps

(gdb) run auto/scheme.tlo
Starting program: C:\cygwin\home\Eion\telegram-purple-dev-1.2.3\tgl\generate.exe auto/scheme.tlo
[New Thread 1404.0x2914]
[New Thread 1404.0x1468]
[New Thread 1404.0x1a8c]

Program received signal SIGSEGV, Segmentation fault.
0x00401614 in new_tree_node_tl_type (x=0xd71a68, y=41) at generate.c:79
79      DEFINE_TREE (tl_type, struct tl_type *, tl_type_name_cmp, 0)
(gdb) bt full
#0  0x00401614 in new_tree_node_tl_type (x=0xd71a68, y=41) at generate.c:79
        T = 0x773f2bfe <ntdll!RtlAllocateHeap+46>
#1  0x0040174e in tree_insert_tl_type (T=0x0, x=0xd71a68, y=41) at generate.c:79
No locals.
#2  0x0040237b in tl_type_insert_by_name (t=0xd71a68) at generate.c:97
No locals.
#3  0x0040a505 in read_types () at generate.c:2281
        t = 0xd71a68
#4  0x0040cf9d in parse_tlo_file () at generate.c:2855
        i = 0
        j = 7798732
#5  0x0040d87e in main (argc=2, argv=0xd71670) at generate.c:3026
        i = -1
        fd = 3
(gdb)

Document CAPTION

telegram-cli: lua-tg.c:1215: lua_do_all: Assertion `p + l + 1 <= pos' failed.
SIGNAL received
h./tg/bin/telegram-cli(print_backtrace+0x20)[0x46edb0]
./tg/bin/telegram-cli(termination_signal_handler+0x64)[0x46ee34]
/lib/x86_64-linux-gnu/libc.so.6(+0x36cb0)[0x7f0235752cb0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37)[0x7f0235752c37]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x148)[0x7f0235756028]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fbf6)[0x7f023574bbf6]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fca2)[0x7f023574bca2]
./tg/bin/telegram-cli(lua_do_all+0x16b)[0x4866ab]
./tg/bin/telegram-cli(net_loop+0xbc)[0x47034c]
./tg/bin/telegram-cli(loop+0x187)[0x471637]
./tg/bin/telegram-cli(main+0x2e5)[0x46d615]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f023573df45]
./tg/bin/telegram-cli[0x46d725]

Allow use of different crypto libraries for GPL compliance

I've been thinking about ways of how to resolve some GPL licensing issue in telegram-purple (see majn/telegram-purple#1), which is caused by the hard dependency on OpenSSL in libtgl. I'm probably not the only one that might run into this issue, since the OpenSSL license is incompatible with the GPL and not every project has the ability to add a GPL exception for OpenSSL.

I think one good way to solve this would be to provide a way to pass a struct of crypto functions to use instead of using OpenSSL statically, and providing a way to compile libtgl without OpenSSL. This would allow others to compile it with something like libgcrypt if GPL-compliance is a hard dependency.

Im working on a pull request to patch that functionality, is there is any chance that you would merge such a thing?

Error when loading an image of a expired forwarded message(image) originated from a bot (Empty Message)

PR Fix: vysheng/tgl/pull#106

I'm using tvdstaaij/telegram-history-dump to archive my chats, and when it hits a forwarded message of a bot message that has expired vysheng/tg will crash with the error below when calling tgl_do_load_photo on an ID of an Empty Message. The empty message still has the contents of the forwarded message when you request the history which is the issue causing this. This fix works seamlessly across the various clients.

Should this fix also be applied other tgl_do_load_(media type here)?

Crash on vysheng/tg when doing load_photo on an Empty Message:

SIGNAL received
hbin/telegram-cli(print_backtrace+0x2f)[0x46ef1f]
bin/telegram-cli(termination_signal_handler+0x64)[0x46efb4]
/lib/x86_64-linux-gnu/libc.so.6(+0x354a0)[0x7fbe9abd44a0]
bin/telegram-cli(tgl_do_load_photo+0x0)[0x4a0e80]
bin/telegram-cli(interpreter_ex+0x970)[0x478e50]
bin/telegram-cli[0x46f501]
/usr/lib/x86_64-linux-gnu/libevent-2.0.so.5(+0x188da)[0x7fbe9c0a38da]
/usr/lib/x86_64-linux-gnu/libevent-2.0.so.5(event_base_loop+0x7fc)[0x7fbe9c098a0c]
bin/telegram-cli(net_loop+0xa7)[0x470557]
bin/telegram-cli(loop+0x183)[0x4718c3]
bin/telegram-cli(main+0x2e5)[0x46d745]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fbe9abbf830]
bin/telegram-cli(_start+0x29)[0x46d859]

Example of an Empty Message:
Empty Message

Example of an Empty Message in history:
exactly the same as a forwarded message(image)

Must check received Diffie-Hellman ephemeral in MTProto

The code for checking the received DH ephemeral in telegram-cli seems to not follow the protocol spec.
See https://github.com/vysheng/tgl/blob/master/mtproto-utils.c#L74

This code does not verify that 1 < g_a < p-1 as required by MTProto (See "g_a and g_b validation" in https://core.telegram.org/mtproto/security_guidelines).

Not checking g_a enables a serious man-in-the-middle (MitM) attack: the MitM sets g_a to 1 on one side, g_b to 1 on the other side, and the shared secret is set to 1, making the channel open to the MitM (even if the two parties verify the hash of the shared secret)

Am I wrong, is this check on g_a coded somewhere else?
Otherwise, can we modify tglmp_check_g_a to check that 1 < g_a < p-1.
This should be fairly easy to code using BN_cmp.

Best,
Karthik

.bin extension on zip files

Hello,

1.I have a problem with load_document, When i use this function to download .zip files or .rar files the file name will be renamed to .bin.

2.The other problem that i have faced is How i can have a real file name in any load_ function specially load_photo, load_video ??

tgl_timer_methods.insert called too often

While investigating a new bug, I noticed that tgl calls .insert before the old timer happened, and without calling .remove first.

Here's a backtrace: http://pastebin.com/ihdTvwfc

Here's my summary:

  • tgl_timer_insert (in telegram-purple), called by:
  • tree_act_ex_query (in queries.c:113), called by:
  • tree_act_ex_query (in queries.c:113), called by:
  • tree_act_ex_query (in queries.c:113), called by:
  • tree_act_ex_query (in queries.c:113), called by:
  • tglq_regen_queries_from_old_session (in queries.c:199), called by:
  • rpc_execute_answer (in mtproto-client.c:831), called by:
  • rpc_execute_answer (in mtproto-client.c:831), called by:
  • rpc_execute_answer (in mtproto-client.c:831), called by:
  • rpc_execute_answer (in mtproto-client.c:831), called by:
  • rpc_execute (in mtproto-client.c:1148)

I think this is a impendence mismatch in tree_act_ex_query: It calls itself recursively, which calls tglq_regen_queries_from_old_session (given as argument), which again calls tree_act_ex_query recursively.

channel message counter

how add this to

void tgl_do_messages_mark_read

function for channel counter increase ?

out_int(CODE_messages_get_messages_views);
out_int (tgl_get_peer_id (id));
out_long (id.access_hash);
out=>>>msgid !!!
out_int (1);//true

Wishlist: Propagate errors, don't just exit

Specifically, tglmp_on_start (when no valid RSA keys were found) in mtproto-client.c:1305

As there's no feedback from tgl about whether loading the key worked or not, the wrapping application has to duplicate lots of checks (e.g. key size, exponent sanity, etc), which is brittle and unreliable.

Suggested resolutions:

  • tgl_set_rsa_key{,_direct} return a "boolean", and tglmp_on_start just asserts that at least one key exists (because then it would be a programmer error if it doesn't).
  • tglmp_on_start returns a "boolean"
  • both of the above

In an unrelated note, there's also rpc_execute which makes a direct call to exit (when an invalid state/response pair is detected) in mtproto-client.c:1207.

Segfault in alarm_query/tglmp_encrypt_send_message/init_enc_msg from telegram-purple

Shortly after logging in with telegram-purple, I get the following segfault. Not sure if the issue is here or in telegram-purple, but I guess it belongs here.

The segfault used to be reproducible every time, now valgrind still throws invalid reads but it doesn't segfault.

Versions: tgl: 1bb8125 / telegram-purple majn/telegram-purple@489535f

DEBUG prpl-telegram: Alarm query 10820207842070576

Program received signal SIGSEGV, Segmentation fault.
0x00007fffddc173fd in init_enc_msg (TLS=0x61c00003e880, S=0x6060000149c0, useful=0) at tgl/mtproto-client.c:705
705       assert (DC->state == st_authorized);
(gdb) bt full
#0  0x00007fffddc173fd in init_enc_msg (TLS=0x61c00003e880, S=0x6060000149c0, useful=0) at tgl/mtproto-client.c:705
        DC = 0x61a07a00000d
        __PRETTY_FUNCTION__ = "init_enc_msg"
#1  0x00007fffddc17815 in tglmp_encrypt_send_message (TLS=0x61c00003e880, c=0x60f0000051d0, msg=0x7fffe744e300 <__packet_buffer+64>, msg_ints=36, flags=2) at tgl/mtproto-client.c:765
        DC = 0x61a000042c80
        S = 0x6060000149c0
        __PRETTY_FUNCTION__ = "tglmp_encrypt_send_message"
        UNENCSZ = 24
        l = -574510222
#2  0x00007fffddc1baf6 in alarm_query (TLS=0x61c00003e880, q=0x60b0000201d0) at tgl/queries.c:103
        __PRETTY_FUNCTION__ = "alarm_query"
#3  0x00007fffddc1bda5 in alarm_query_gateway (TLS=0x61c00003e880, arg=0x60b0000201d0) at tgl/queries.c:142
No locals.
#4  0x00007fffddbfc77c in timer_alarm (arg=0x6030000421c0) at tgp-timers.c:34
        t = 0x6030000421c0
#5  0x00007ffff67333c3 in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#6  0x00007ffff673291d in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#7  0x00007ffff6732cf8 in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#8  0x00007ffff6733022 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#9  0x00005555555c6141 in b_main_run () at events_glib.c:59
No locals.
#10 0x00005555555c030c in main (argc=2, argv=0x7fffffffe2a8) at unix.c:170
        i = 0
        old_cwd = 0x0
        sig = {__sigaction_handler = {sa_handler = 0x5555555c0d2d <sighandler_shutdown>, sa_sigaction = 0x5555555c0d2d <sighandler_shutdown>}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = -2147483648, sa_restorer = 0x0}
        old = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0, 0, 140737328074843, 140737488347552, 140737488347056, 17592186043392, 140737488347136, 140737488347136, 93824992699415, 0, 0,
              93824992412715, 30064771073, 93824995281696, 140737336460257, 140737488347552}}, sa_flags = 0, sa_restorer = 0x0}

Valgrind:

DEBUG prpl-telegram: Alarm query 10821508072580676
==4104== Invalid read of size 8
==4104==    at 0x1242EA1A: alarm_query (queries.c:94)
==4104==    by 0x1242EDA4: alarm_query_gateway (queries.c:142)
==4104==    by 0x1240F77B: timer_alarm (tgp-timers.c:34)
==4104==    by 0x53893C2: ??? (in /usr/lib/libglib-2.0.so.0.4200.1)
==4104==    by 0x538891C: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.4200.1)
==4104==    by 0x5388CF7: ??? (in /usr/lib/libglib-2.0.so.0.4200.1)
==4104==    by 0x5389021: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.4200.1)
==4104==    by 0x131CA1: b_main_run (events_glib.c:59)
==4104==    by 0x12FA9A: main (unix.c:170)
==4104==  Address 0x205c0928 is 8 bytes inside a block of size 56 free'd
==4104==    at 0x4C2B200: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4104==    by 0x124561C7: tgl_free_release (tools.c:121)
==4104==    by 0x1242D863: tgls_free_session (mtproto-client.c:1432)
==4104==    by 0x1242B8A2: fail_session (mtproto-client.c:1039)
==4104==    by 0x1242C17D: process_rpc_message (mtproto-client.c:1137)
==4104==    by 0x1242C4CA: rpc_execute (mtproto-client.c:1191)
==4104==    by 0x1240F398: try_rpc_read (tgp-net.c:428)
==4104==    by 0x1240F5B6: try_read (tgp-net.c:474)
==4104==    by 0x1240E9C0: conn_try_read (tgp-net.c:244)
==4104==    by 0x131D2F: gaim_io_invoke (events_glib.c:86)
==4104==    by 0x538891C: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.4200.1)
==4104==    by 0x5388CF7: ??? (in /usr/lib/libglib-2.0.so.0.4200.1)
==4104==

Rest of the valgrind output: http://dump.dequis.org/fHSEu.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.