Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nullptr derefence in the source .\tgl-master\queries.c #134

Open
ghsrcgh opened this issue Nov 19, 2017 · 1 comment
Open

nullptr derefence in the source .\tgl-master\queries.c #134

ghsrcgh opened this issue Nov 19, 2017 · 1 comment

Comments

@ghsrcgh
Copy link

ghsrcgh commented Nov 19, 2017

Details of the nullptr dereference is written in that ticket: majn/telegram-purple#431

I will copy most important part from comment:

nullptr derefence in the source .\tgl-master\queries.c (my comments are started with "//"):

int tglq_query_error (struct tgl_state *TLS, long long id) {
  assert (fetch_int () == CODE_rpc_error);
  int error_code = fetch_int ();
  int error_len = prefetch_strlen ();
  char *error = fetch_str (error_len);

  struct query *q = tglq_query_get (TLS, id);
  // (q == nullptr)?
  if (!q)
  {
      vlogprintf (E_WARNING, "error for query '%s' #%" INT64_PRINTF_MODIFIER "d: #%d :%.*s\n", q->methods->name, id, error_code, error_len, error);
      // q == nullptr and you are trying to dereferencing null pointer?! q->methods ... ?! WTF??!
      // it is crashing here with an access violation (C.O.)
      vlogprintf (E_WARNING, "No such query\n");
  }
  else
  {

You cannot defererence q->methods here, because q is nullptr! It is a bug in source.

@BenWiederhake
Copy link
Contributor

Awesome, thanks! Our fork of this library already contains the fix in commit ac2e73b since February, and in dev-1.4.0 at least since June.

If you were experiencing crashes with telegram-purple, I strongly recommend upgrading to the intermediate branch dev-1.4.0. (Don't forget git submodule sync && git submodule update!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants