Exemple #1
0
int EXPORT_CC
libxrdp_process_data(struct xrdp_session* session)
{
  int cont;
  int rv;
  int code;
  int term;
  int dead_lock_counter;

  term = 0;
  cont = 1;
  rv = 0;
  dead_lock_counter = 0;
  while ((cont || !session->up_and_running) && !term)
  {
    if (session->is_term != 0)
    {
      if (session->is_term())
      {
        term = 1;
      }
    }
    code = 0;
    if (xrdp_rdp_recv((struct xrdp_rdp*)(session->rdp),
                      session->s, &code) != 0)
    {
      rv = 1;
      break;
    }
    DEBUG(("libxrdp_process_data code %d", code));
    switch (code)
    {
      case -1:
        xrdp_rdp_send_demand_active((struct xrdp_rdp*)session->rdp);
        session->up_and_running = 0;
        break;
      case 0:
        dead_lock_counter++;
        break;
      case RDP_PDU_CONFIRM_ACTIVE: /* 3 */
        xrdp_rdp_process_confirm_active((struct xrdp_rdp*)session->rdp,
                                        session->s);
        break;
      case RDP_PDU_DATA: /* 7 */
        if (xrdp_rdp_process_data((struct xrdp_rdp*)session->rdp,
                                  session->s) != 0)
        {
          DEBUG(("libxrdp_process_data returned non zero"));
          cont = 0;
          term = 1;
        }
        break;
      default:
        g_writeln("unknown in libxrdp_process_data");
        dead_lock_counter++;
        break;
    }
    if (dead_lock_counter > 100000)
    {
      /*This situation can happen and this is a workaround*/
      cont = 0;
      g_writeln("Serious programming error we were locked in a deadly loop") ;
      g_writeln("remaining :%d",session->s->end-session->s->next_packet);
      session->s->next_packet = 0;
    }
    if (cont)
    {
      cont = (session->s->next_packet != 0) &&
             (session->s->next_packet < session->s->end);
    }
  }
  return rv;
}
Exemple #2
0
int EXPORT_CC
libxrdp_process_data(struct xrdp_session *session, struct stream *s)
{
    int cont;
    int rv;
    int code;
    int term;
    int dead_lock_counter;
    int do_read;
    struct xrdp_rdp *rdp;

    do_read = s == 0;
    if (do_read && session->up_and_running)
    {
        g_writeln("libxrdp_process_data: error logic");
        return 1;
    }
    if (session->in_process_data != 0)
    {
        g_writeln("libxrdp_process_data: error reentry");
        return 1;
    }
    session->in_process_data++;

    term = 0;
    cont = 1;
    rv = 0;
    dead_lock_counter = 0;

    rdp = (struct xrdp_rdp *) (session->rdp);

    while ((cont || !session->up_and_running) && !term)
    {
        if (session->is_term != 0)
        {
            if (session->is_term())
            {
                term = 1;
                break;
            }
        }

        code = 0;

        if (do_read)
        {
            if (s == 0)
            {
                s = libxrdp_force_read(session->trans);
            }
            else
            {
                if ((s->next_packet == 0) || (s->next_packet >= s->end))
                {
                    s = libxrdp_force_read(session->trans);
                }
            }
            if (s == 0)
            {
                g_writeln("libxrdp_process_data: libxrdp_force_read failed");
                rv = 1;
                break;
            }
        }

        if (xrdp_rdp_recv(rdp, s, &code) != 0)
        {
            g_writeln("libxrdp_process_data: xrdp_rdp_recv failed");
            rv = 1;
            break;
        }

        DEBUG(("libxrdp_process_data code %d", code));

        switch (code)
        {
            case -1:
                xrdp_caps_send_demand_active(rdp);
                session->up_and_running = 0;
                break;
            case 0:
                dead_lock_counter++;
                break;
            case RDP_PDU_CONFIRM_ACTIVE: /* 3 */
                xrdp_caps_process_confirm_active(rdp, s);
                break;
            case RDP_PDU_DATA: /* 7 */
                if (xrdp_rdp_process_data(rdp, s) != 0)
                {
                    DEBUG(("libxrdp_process_data returned non zero"));
                    cont = 0;
                    term = 1;
                }
                break;
            case 2: /* FASTPATH_INPUT_EVENT */
                if (xrdp_fastpath_process_input_event(rdp->sec_layer->fastpath_layer, s) != 0)
                {
                     DEBUG(("libxrdp_process_data returned non zero"));
                     cont = 0;
                     term = 1;
                }
                break;
            default:
                g_writeln("unknown in libxrdp_process_data: code= %d", code);
                dead_lock_counter++;
                break;
        }

        if (dead_lock_counter > 100000)
        {
            /*This situation can happen and this is a workaround*/
            cont = 0;
            g_writeln("Serious programming error we were locked in a deadly loop") ;
            g_writeln("remaining :%d", s->end - s->next_packet);
            s->next_packet = 0;
        }

        if (cont)
        {
            cont = (s->next_packet != 0) && (s->next_packet < s->end);
        }
    }

    session->in_process_data--;

    return rv;
}
Exemple #3
0
int EXPORT_CC
libxrdp_process_data(struct xrdp_session* session)
{
  int cont;
  int rv;
  int code;
  int term;
  tui8 header;

  term = 0;
  cont = 1;
  rv = 0;
  while ((cont || !session->up_and_running) && !term)
  {
    if (session->is_term != 0)
    {
      if (session->is_term())
      {
        term = 1;
      }
    }
    code = 0;
    if (xrdp_rdp_recv((struct xrdp_rdp*)session->rdp, session->s, &code) != 0)
    {
      rv = 1;
      break;
    }
    DEBUG(("libxrdp_process_data code %d", code));
    switch (code)
    {
      case -1:
        xrdp_rdp_send_demand_active((struct xrdp_rdp*)session->rdp);
        session->up_and_running = 0;
        break;
      case 0:
        break;
      case RDP_PDU_CONFIRM_ACTIVE: /* 3 */
        xrdp_rdp_process_confirm_active((struct xrdp_rdp*)session->rdp,
                                        session->s);
        break;
      case RDP_PDU_DATA: /* 7 */
        //g_writeln("%08x %08x %08x %08x\n",*(tui32*)session->s->p, *(tui32*)(session->s->p+4),
	//				*(tui32*)(session->s->p+8),*(tui32*)(session->s->p+12));
        if (xrdp_rdp_process_data((struct xrdp_rdp*)session->rdp,
                                  session->s) != 0)
        {
          DEBUG(("libxrdp_process_data returned non zero"));
          cont = 0;
          term = 1;
        }
        break;
      default:
        g_writeln("unknown in libxrdp_process_data");
        break;
    }
    if (cont)
    {
      cont = (session->s->next_packet != 0) &&
             (session->s->next_packet < session->s->end);
    }
  }
  return rv;
}