Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler.
Number of rules (primarily dangerous function names) in C/C++ ruleset: 223
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/LICENSE.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/telegram.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/event-old.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/python-types.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/python-types.c
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.h
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c
Examining data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c

FINAL RESULTS:

data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:156:129:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
void fail_interface (struct tgl_state *TLS, struct in_ev *ev, int error_code, const char *format, ...) __attribute__ (( format (printf, 4, 5)));
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:182:88:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
static void socket_answer_add_printf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:187:24:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  socket_answer_pos += vsnprintf (socket_answer + socket_answer_pos, SOCKET_ANSWER_MAX_SIZE - socket_answer_pos, format, ap);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:205:10:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
  else { printf (__VA_ARGS__); } 
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:576:10:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
    l += snprintf (buf + l, 999 - l, COLOR_RED "%.*s " COLOR_NORMAL, 100, U->print_name);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:579:10:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
    l += snprintf (buf + l, 999 - l, COLOR_RED "[");
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:595:10:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
    l += snprintf (buf + l, 999 - l, "]" COLOR_NORMAL);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2284:19:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  int error_len = vsnprintf (error, 1000, format, ap);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2602:7:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  if (snprintf (buf, sizeof (buf), OPEN_BIN, name) >= (int) sizeof (buf)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2607:7:  [4] (shell) execl:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
      execl("/bin/sh", "sh", "-c", buf, (char *) 0);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3330:14:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
      pos += sprintf (q + pos, "%08x%s", card[i], i == size - 1 ? "" : ":");
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3801:5:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
    printf (COLOR_GREY);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3811:3:  [4] (format) vfprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
  vfprintf (stdout, format, ap);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3814:5:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
    printf (COLOR_NORMAL);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.h:43:64:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
void rprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.h:44:66:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
void logprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:280:7:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
  if (access (config_filename, R_OK) != 0) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:307:3:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
  strcpy (buf + l, param_name);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:975:5:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
    printf (
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:172:20:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
  home_directory = getenv("TELEGRAM_HOME");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:174:20:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
  home_directory = getenv("HOME");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:193:22:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
  config_directory = getenv("TELEGRAM_CONFIG_DIR");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:196:22:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
  config_directory = getenv("XDG_CONFIG_HOME");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:655:17:  [3] (buffer) getopt_long:
  Some older implementations do not protect against internal buffer overflows
  (CWE-120, CWE-20). Check implementation on installation, or limit the size
  of all string inputs.
  while ((opt = getopt_long (argc, argv, "u:hk:vNl:fEwWCRAdL:DU:G:qP:S:e:I6b"
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:175:8:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
static char socket_answer[SOCKET_ANSWER_MAX_SIZE + 1];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:194:12:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    static char s[100];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:195:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (s, "ANSWER %d\n", socket_answer_pos);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:222:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char cur_token_buff[(1 << 20) + 1];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:379:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char buf[2 * sizeof (tgl_message_id_t) + 1];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:384:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buf + 2 * i, "%02x", (unsigned)s[i]);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:390:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char buf[2 * sizeof (tgl_peer_id_t) + 2];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:396:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buf + 1 + 2 * i, "%02x", (unsigned)s[i]);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:516:15:  [2] (integer) atoi:
  Unless checked, the resulting number can exceed the expected range
  (CWE-190). If source untrusted, check both minimum and maximum, even if the
  input had no minus sign (large numbers can roll over into negative number;
  consider saving to an unsigned value if that is intended).
      int r = atoi (sc + x);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:571:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char buf[1000];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:749:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char stat_buf[1 << 15];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1292:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char *colors[4] = {COLOR_GREY, COLOR_CYAN, COLOR_BLUE, COLOR_GREEN};
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1293:19:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static unsigned char buf[16];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1497:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
      static char s[1000]; \
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1498:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "https://maps.google.com/?q=%.6lf,%.6lf", M->media.geo.latitude, M->media.geo.longitude);\
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1524:22:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO(photo, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1525:22:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO(video, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1526:22:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO(audio, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1527:25:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO(document, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1528:21:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO(file, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1529:28:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO_THUMB(video, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1530:31:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO_THUMB(document, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1531:27:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO_THUMB(file, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1532:20:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
DO_LOAD_PHOTO(any, open, open_filename_gw)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2108:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy (*R + 1, u, strlen (u) + 1);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2280:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char error[1001];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2601:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char buf[PATH_MAX];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2960:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy (unread_message_list + unread_message_count, list, num * sizeof (void *));
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3326:12:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    static char q[1000];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3738:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy (saved_line, rl_line_buffer, rl_end);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3822:7:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
const char *color_stack[10];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.h:59:3:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  char in_buf[4096];
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:42:10:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
  return sprintf (string, "%04d-%02d-%02d %02d:%02d:%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:51:12:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    static char s[20];
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:121:12:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    static char s[100];
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:124:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "user#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:127:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "chat#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:130:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "channel#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:133:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "encr_chat#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/json-tg.c:492:12:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    static char s[20];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:117:1:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
char one_string[MAX_ONE_STRING_LEN + 1];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:123:1:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
char *one_string_results[10];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:406:23:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  int state_file_fd = open (get_state_filename (), O_CREAT | O_RDWR, 0600);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:440:23:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  int state_file_fd = open (get_state_filename (), O_CREAT | O_RDWR, 0600);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:479:22:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  int auth_file_fd = open (get_auth_key_filename (), O_CREAT | O_RDWR, 0600);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:523:24:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  int secret_chat_fd = open (get_secret_chat_filename (), O_CREAT | O_RDWR, 0600);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:548:3:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  char ip[100];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:553:19:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static unsigned char auth_key[256];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:582:22:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  int auth_file_fd = open (get_auth_key_filename (), O_CREAT | O_RDWR, 0600);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:623:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char s[1000];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:624:19:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static unsigned char key[256];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:625:19:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static unsigned char sha[20];
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:671:24:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  int secret_chat_fd = open (get_secret_chat_filename (), O_RDWR, 0600);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:237:12:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    static char s[100];
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:240:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "user#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:243:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "chat#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:246:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "encr_chat#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:249:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (s, "channel#%d", tgl_get_peer_id (id));
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:282:22:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
    config_file_fd = open (config_filename, O_CREAT | O_RDWR, 0600);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:298:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char buf[1000]; 
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:302:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy (buf, prefix, l);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:338:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  static char buf[1000];
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:342:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy (buf, prefix, l);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:347:3:  [2] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused). Risk is low because the source is a constant string.
  strcpy (buf + l, "test");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:353:3:  [2] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused). Risk is low because the source is a constant string.
  strcpy (buf + l, "log_level");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:359:5:  [2] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused). Risk is low because the source is a constant string.
    strcpy (buf + l, "msg_num");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:378:3:  [2] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused). Risk is low because the source is a constant string.
  strcpy (buf + l, "binlog_enabled");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:385:3:  [2] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused). Risk is low because the source is a constant string.
  strcpy (buf + l, "pfs_enabled");
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:520:13:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  if ((fd = open ("/dev/null", O_RDWR, 0)) != -1) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:528:24:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
  if (logname && (fd = open (logname, O_WRONLY|O_APPEND|O_CREAT, 0640)) != -1) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:715:19:  [2] (integer) atoi:
  Unless checked, the resulting number can exceed the expected range
  (CWE-190). If source untrusted, check both minimum and maximum, even if the
  input had no minus sign (large numbers can roll over into negative number;
  consider saving to an unsigned value if that is intended).
      log_level = atoi (optarg);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:767:14:  [2] (integer) atoi:
  Unless checked, the resulting number can exceed the expected range
  (CWE-190). If source untrusted, check both minimum and maximum, even if the
  input had no minus sign (large numbers can roll over into negative number;
  consider saving to an unsigned value if that is intended).
      port = atoi (optarg);
data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c:1340:3:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
  char filename[1024];
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:160:23:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  return s && word && strlen (word) == l && !memcmp (s, word, l);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:196:36:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bufferevent_write (ev->bev, s, strlen (s));
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:514:13:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    int x = strlen (ss[i]);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:830:75:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
#define ARG2STR_DEF(n,def) args[n].str ? args[n].str : def, args[n].str ? strlen (args[n].str) : strlen (def)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:830:98:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
#define ARG2STR_DEF(n,def) args[n].str ? args[n].str : def, args[n].str ? strlen (args[n].str) : strlen (def)
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:831:47:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
#define ARG2STR(n) args[n].str, args[n].str ? strlen (args[n].str) : 0
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:904:114:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  tgl_do_send_document (TLS, args[0].peer_id, args[1].str, arg_num == 2 ? NULL : args[2].str, arg_num == 2 ? 0 : strlen (args[2].str), flags | TGL_SEND_MSG_FLAG_REPLY (reply_id), print_msg_success_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:951:115:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  tgl_do_reply_document (TLS, &args[0].msg_id, args[1].str, arg_num == 2 ? NULL : args[2].str, arg_num == 2 ? 0 : strlen (args[2].str), flags, print_msg_success_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1034:72:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  tgl_do_send_broadcast (TLS, arg_num - 1, ids, args[arg_num - 1].str, strlen (args[arg_num - 1].str), disable_msg_preview | do_html, print_msg_list_success_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1206:45:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    tgl_do_add_contact (TLS, P->user.phone, strlen (P->user.phone), args[1].str, strlen (args[1].str), args[2].str, strlen (args[2].str), 0, print_user_list_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1206:82:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    tgl_do_add_contact (TLS, P->user.phone, strlen (P->user.phone), args[1].str, strlen (args[1].str), args[2].str, strlen (args[2].str), 0, print_user_list_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1206:117:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    tgl_do_add_contact (TLS, P->user.phone, strlen (P->user.phone), args[1].str, strlen (args[1].str), args[2].str, strlen (args[2].str), 0, print_user_list_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1223:11:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  int l = strlen (s);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1427:44:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  tgl_do_contact_search (TLS, args[0].str, strlen (args[0].str), print_peer_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:1589:82:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  tgl_do_msg_search (TLS, args[0].peer_id, from, to, limit, offset, args[5].str, strlen (args[5].str), print_msg_list_gw, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2102:14:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    if ((int)strlen (u) < len || memcmp (u, text, len)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2106:18:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    *R = malloc (strlen (u) + 2);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2108:24:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    memcpy (*R + 1, u, strlen (u) + 1);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2137:11:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    len = strlen (text);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2870:7:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  if (strlen (line) > 0) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:2871:51:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    tgl_do_send_message (TLS, chat_mode_id, line, strlen (line), 0, NULL, 0, 0);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3457:34:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    tgl_do_send_extf (TLS, line, strlen (line), callback_extf, ev);
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3850:39:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
      } else if (M->photo->caption && strlen (M->photo->caption)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3876:35:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
      if (M->document->caption && strlen (M->document->caption)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:3926:40:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
      if (M->encr_document->caption && strlen (M->encr_document->caption)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:4053:40:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    } else if (!U->user.first_name || !strlen (U->user.first_name)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:4055:39:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    } else if (!U->user.last_name || !strlen (U->user.last_name)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:4440:21:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  if (M->message && strlen (M->message)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/interface.c:4444:23:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    if (M->message && strlen (M->message)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:261:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    int r = read (0, &c, 1);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:288:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  int r = read (0, line_buffer + line_buffer_pos, line_buffer_size - line_buffer_pos);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:411:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read (state_file_fd, &magic, 4) < 4) { close (state_file_fd); return; }
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:413:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read (state_file_fd, &version, 4) < 4) { close (state_file_fd); return; }
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:416:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read (state_file_fd, x, 16) < 16) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:470:11:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  int l = strlen (DC->options[0]->ip);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:503:11:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  int l = strlen (P->print_name);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:544:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (auth_file_fd, &port, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:546:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (auth_file_fd, &l, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:549:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (auth_file_fd, ip, l) == l);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:554:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (auth_file_fd, &auth_key_id, 8) == 8);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:555:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (auth_file_fd, auth_key, 256) == 256);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:565:58:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 1, "", 0, TG_SERVER_TEST_1, strlen (TG_SERVER_TEST_1), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:566:58:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 2, "", 0, TG_SERVER_TEST_2, strlen (TG_SERVER_TEST_2), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:567:58:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 3, "", 0, TG_SERVER_TEST_3, strlen (TG_SERVER_TEST_3), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:570:53:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 1, "", 0, TG_SERVER_1, strlen (TG_SERVER_1), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:571:53:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 2, "", 0, TG_SERVER_2, strlen (TG_SERVER_2), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:572:53:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 3, "", 0, TG_SERVER_3, strlen (TG_SERVER_3), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:573:53:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 4, "", 0, TG_SERVER_4, strlen (TG_SERVER_4), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:574:53:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    bl_do_dc_option (TLS, 0, 5, "", 0, TG_SERVER_5, strlen (TG_SERVER_5), 443);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:590:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read (auth_file_fd, &m, 4) < 4 || (m != DC_SERIALIZED_MAGIC)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:595:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (auth_file_fd, &x, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:598:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (auth_file_fd, &dc_working_num, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:603:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    assert (read (auth_file_fd, &y, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:610:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  int l = read (auth_file_fd, &our_id, 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:626:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &id, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:628:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &l, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:630:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, s, l) == l);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:631:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &user_id, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:632:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &admin_id, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:633:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &date, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:634:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &ttl, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:635:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &layer, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:636:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &access_hash, 8) == 8);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:637:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &state, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:638:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &key_fingerprint, 8) == 8);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:639:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, &key, 256) == 256);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:640:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (fd, sha, 20) == 20);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:643:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    assert (read (fd, &in_seq_no, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:644:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    assert (read (fd, &last_in_seq_no, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:645:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    assert (read (fd, &out_seq_no, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:675:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read (secret_chat_fd, &x, 4) < 4) { close (secret_chat_fd); return; }
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:678:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (secret_chat_fd, &v, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/loop.c:680:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  assert (read (secret_chat_fd, &x, 4) == 4);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:69:19:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  assert (name && strlen (name));
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:70:18:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  if (!value || !strlen (value)) { return; }
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:78:19:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  assert (name && strlen (name));
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:87:18:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  if (!value || !strlen (value)) { return; }
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:95:19:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  assert (name && strlen (name));
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1141:40:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
#define LUA_STR_ARG(n) lua_ptr[n].str, strlen (lua_ptr[n].str)
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1523:43:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
        peer_id = parse_input_peer_id (s, strlen (s), TGL_PEER_USER);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1525:43:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
        peer_id = parse_input_peer_id (s, strlen (s), TGL_PEER_CHAT);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1527:43:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
        peer_id = parse_input_peer_id (s, strlen (s), TGL_PEER_ENCR_CHAT);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1529:43:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
        peer_id = parse_input_peer_id (s, strlen (s), TGL_PEER_CHANNEL);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1531:43:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
        peer_id = parse_input_peer_id (s, strlen (s), 0);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1569:56:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
      lua_ptr[pos + p].msg_id = parse_input_msg_id (s, strlen (s));
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1846:16:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    if (!s || !strlen (s)) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1851:15:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    int len = strlen (s);
data/telegram-cli-1.3.1+git20160323.6547c0b21/lua-tg.c:1860:18:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
      if (len == strlen (#name) && !strncmp (s, #name, len)) {\
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:167:29:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  return ((str == NULL) || (strlen(str) < 1));
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:288:57:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    if (write (config_file_fd, DEFAULT_CONFIG_CONTENTS, strlen (DEFAULT_CONFIG_CONTENTS)) <= 0) {
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:301:9:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    l = strlen (prefix);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:341:9:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    l = strlen (prefix);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:705:15:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
      assert (strlen (prefix) <= 100);
data/telegram-cli-1.3.1+git20160323.6547c0b21/main.c:943:13:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    assert (strlen (unix_socket) < 100);
data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c:114:19:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  assert (name && strlen (name));
data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c:115:18:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  if (!value || !strlen (value)) { return; }
data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c:124:18:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  if (!value || !strlen (value)) { return; }
data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c:133:19:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  assert (name && strlen (name));
data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c:1341:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(filename, file, 1024);
data/telegram-cli-1.3.1+git20160323.6547c0b21/python-tg.c:1358:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(filename, file, 1024);

ANALYSIS SUMMARY:

Hits = 197
Lines analyzed = 12448 in approximately 0.33 seconds (38016 lines/second)
Physical Source Lines of Code (SLOC) = 10549
Hits@level = [0]  71 [1] 100 [2]  73 [3]   5 [4]  19 [5]   0
Hits@level+ = [0+] 268 [1+] 197 [2+]  97 [3+]  24 [4+]  19 [5+]   0
Hits/KSLOC@level+ = [0+] 25.4053 [1+] 18.6748 [2+] 9.19518 [3+] 2.2751 [4+] 1.80112 [5+]   0
Dot directories skipped = 1 (--followdotdir overrides)
Minimum risk level = 1
Not every hit is necessarily a security vulnerability.
There may be other security vulnerabilities; review your code!
See 'Secure Programming HOWTO'
(https://dwheeler.com/secure-programs) for more information.