Example #1
0
int APP_CC
xrdp_caps_process_confirm_active(struct xrdp_rdp *self, struct stream *s)
{
    int cap_len;
    int source_len;
    int num_caps;
    int index;
    int type;
    int len;
    char *p;

    DEBUG(("in xrdp_caps_process_confirm_active"));
    in_uint8s(s, 4); /* rdp_shareid */
    in_uint8s(s, 2); /* userid */
    in_uint16_le(s, source_len); /* sizeof RDP_SOURCE */
    in_uint16_le(s, cap_len);
    in_uint8s(s, source_len);
    in_uint16_le(s, num_caps);
    in_uint8s(s, 2); /* pad */

    if ((cap_len < 0) || (cap_len > 1024 * 1024))
    {
        return 1;
    }

    for (index = 0; index < num_caps; index++)
    {
        p = s->p;
        if (!s_check_rem(s, 4))
        {
            g_writeln("xrdp_caps_process_confirm_active: error 1");
            return 1;
        }
        in_uint16_le(s, type);
        in_uint16_le(s, len);
        if ((len < 4) || !s_check_rem(s, len - 4))
        {
            g_writeln("xrdp_caps_process_confirm_active: error: len %d, "
                      "remaining %d", len, (int) (s->end - s->p));
            return 1;
        }
        len -= 4;
        switch (type)
        {
            case RDP_CAPSET_GENERAL: /* 1 */
                DEBUG(("RDP_CAPSET_GENERAL"));
                xrdp_caps_process_general(self, s, len);
                break;
            case RDP_CAPSET_BITMAP: /* 2 */
                DEBUG(("RDP_CAPSET_BITMAP"));
                break;
            case RDP_CAPSET_ORDER: /* 3 */
                DEBUG(("RDP_CAPSET_ORDER"));
                xrdp_caps_process_order(self, s, len);
                break;
            case RDP_CAPSET_BMPCACHE: /* 4 */
                DEBUG(("RDP_CAPSET_BMPCACHE"));
                xrdp_caps_process_bmpcache(self, s, len);
                break;
            case RDP_CAPSET_CONTROL: /* 5 */
                DEBUG(("RDP_CAPSET_CONTROL"));
                break;
            case 6:
                xrdp_caps_process_cache_v3_codec_id(self, s, len);
                break;
            case RDP_CAPSET_ACTIVATE: /* 7 */
                DEBUG(("RDP_CAPSET_ACTIVATE"));
                break;
            case RDP_CAPSET_POINTER: /* 8 */
                DEBUG(("RDP_CAPSET_POINTER"));
                xrdp_caps_process_pointer(self, s, len);
                break;
            case RDP_CAPSET_SHARE: /* 9 */
                DEBUG(("RDP_CAPSET_SHARE"));
                break;
            case RDP_CAPSET_COLCACHE: /* 10 */
                DEBUG(("RDP_CAPSET_COLCACHE"));
                break;
            case 12: /* 12 */
                DEBUG(("--12"));
                break;
            case 13: /* 13 */
                xrdp_caps_process_input(self, s, len);
                break;
            case 14: /* 14 */
                DEBUG(("--14"));
                break;
            case RDP_CAPSET_BRUSHCACHE: /* 15 */
                xrdp_caps_process_brushcache(self, s, len);
                break;
            case 16: /* 16 */
                DEBUG(("--16"));
                break;
            case 17: /* 17 */
                DEBUG(("CAPSET_TYPE_OFFSCREEN_CACHE"));
                xrdp_caps_process_offscreen_bmpcache(self, s, len);
                break;
            case RDP_CAPSET_BMPCACHE2: /* 19 */
                DEBUG(("RDP_CAPSET_BMPCACHE2"));
                xrdp_caps_process_bmpcache2(self, s, len);
                break;
            case 20: /* 20 */
                DEBUG(("--20"));
                break;
            case 21: /* 21 */
                DEBUG(("--21"));
                break;
            case 22: /* 22 */
                DEBUG(("--22"));
                break;
            case 0x0017: /* 23 CAPSETTYPE_RAIL */
                xrdp_caps_process_rail(self, s, len);
                break;
            case 0x0018: /* 24 CAPSETTYPE_WINDOW */
                xrdp_caps_process_window(self, s, len);
                break;
            case 0x001A: /* 26 CAPSETTYPE_MULTIFRAGMENTUPDATE */
                xrdp_caps_process_multifragmentupdate(self, s, len);
                break;
            case RDP_CAPSET_BMPCODECS: /* 0x1d(29) */
                xrdp_caps_process_codecs(self, s, len);
                break;
            case 0x001E: /* CAPSSETTYPE_FRAME_ACKNOWLEDGE */
                xrdp_caps_process_frame_ack(self, s, len);
                break;
            case RDP_CAPSET_SURFCMDS: /* CAPSETTYPE_SURFACE_COMMANDS */
                xrdp_caps_process_surface_cmds(self, s, len);
                break;
            default:
                g_writeln("unknown in xrdp_caps_process_confirm_active %d", type);
                break;
        }

        s->p = p + len + 4;
    }

    if (self->client_info.no_orders_supported &&
        (self->client_info.offscreen_support_level != 0))
    {
        g_writeln("xrdp_caps_process_confirm_active: not enough orders "
                  "supported by client, client wants off screen bitmap but "
                  "offscreen bitmaps disabled");
        self->client_info.offscreen_support_level = 0;
        self->client_info.offscreen_cache_size = 0;
        self->client_info.offscreen_cache_entries = 0;
    }

    DEBUG(("out xrdp_caps_process_confirm_active"));
    return 0;
}
Example #2
0
int
xrdp_caps_process_confirm_active(struct xrdp_rdp *self, struct stream *s)
{
    int cap_len;
    int source_len;
    int num_caps;
    int index;
    int type;
    int len;
    char *p;

    DEBUG(("in xrdp_caps_process_confirm_active"));
    in_uint8s(s, 4); /* rdp_shareid */
    in_uint8s(s, 2); /* userid */
    in_uint16_le(s, source_len); /* sizeof RDP_SOURCE */
    in_uint16_le(s, cap_len);
    in_uint8s(s, source_len);
    in_uint16_le(s, num_caps);
    in_uint8s(s, 2); /* pad */

    if ((cap_len < 0) || (cap_len > 1024 * 1024))
    {
        return 1;
    }

    for (index = 0; index < num_caps; index++)
    {
        p = s->p;
        if (!s_check_rem(s, 4))
        {
            g_writeln("xrdp_caps_process_confirm_active: error 1");
            return 1;
        }
        in_uint16_le(s, type);
        in_uint16_le(s, len);
        if ((len < 4) || !s_check_rem(s, len - 4))
        {
            g_writeln("xrdp_caps_process_confirm_active: error: len %d, "
                      "remaining %d", len, (int) (s->end - s->p));
            return 1;
        }
        len -= 4;
        switch (type)
        {
            case CAPSTYPE_GENERAL:
                DEBUG(("CAPSTYPE_GENERAL"));
                xrdp_caps_process_general(self, s, len);
                break;
            case CAPSTYPE_BITMAP:
                DEBUG(("CAPSTYPE_BITMAP"));
                break;
            case CAPSTYPE_ORDER:
                DEBUG(("CAPSTYPE_ORDER"));
                xrdp_caps_process_order(self, s, len);
                break;
            case CAPSTYPE_BITMAPCACHE:
                DEBUG(("CAPSTYPE_BMPCACHE"));
                xrdp_caps_process_bmpcache(self, s, len);
                break;
            case CAPSTYPE_CONTROL:
                DEBUG(("CAPSTYPE_CONTROL"));
                break;
            case 6:
                xrdp_caps_process_cache_v3_codec_id(self, s, len);
                break;
            case CAPSTYPE_ACTIVATION:
                DEBUG(("CAPSTYPE_ACTIVAION"));
                break;
            case CAPSTYPE_POINTER:
                DEBUG(("CAPSTYPE_POINTER"));
                xrdp_caps_process_pointer(self, s, len);
                break;
            case CAPSTYPE_SHARE:
                DEBUG(("CAPSTYPE_SHARE"));
                break;
            case CAPSTYPE_COLORCACHE:
                DEBUG(("CAPSTYPE_COLORCACHE"));
                break;
            case CAPSTYPE_SOUND:
                DEBUG(("CAPSTYPE_SOUND"));
                break;
            case CAPSTYPE_INPUT:
                xrdp_caps_process_input(self, s, len);
                break;
            case CAPSTYPE_FONT:
                DEBUG(("CAPSTYPE_FONT"));
                break;
            case CAPSTYPE_BRUSH:
                xrdp_caps_process_brushcache(self, s, len);
                break;
            case CAPSTYPE_GLYPHCACHE:
                DEBUG(("CAPSTYPE_GLYPHCACHE"));
                xrdp_caps_process_glyphcache(self, s, len);
                break;
            case CAPSTYPE_OFFSCREENCACHE:
                DEBUG(("CAPSTYPE_OFFSCREENCACHE"));
                xrdp_caps_process_offscreen_bmpcache(self, s, len);
                break;
            case CAPSTYPE_BITMAPCACHE_REV2:
                DEBUG(("CAPSTYPE_BITMAPCACHE_REV2"));
                xrdp_caps_process_bmpcache2(self, s, len);
                break;
            case CAPSTYPE_VIRTUALCHANNEL:
                DEBUG(("CAPSTYPE_VIRTUALCHANNEL"));
                break;
            case CAPSTYPE_DRAWNINGRIDCACHE:
                DEBUG(("CAPSTYPE_DRAWNINGRIDCACHE"));
                break;
            case CAPSTYPE_DRAWGDIPLUS:
                DEBUG(("CAPSTYPE_DRAWGDIPLUS"));
                break;
            case CAPSTYPE_RAIL:
                xrdp_caps_process_rail(self, s, len);
                break;
            case CAPSTYPE_WINDOW:
                xrdp_caps_process_window(self, s, len);
                break;
            case CAPSSETTYPE_MULTIFRAGMENTUPDATE:
                xrdp_caps_process_multifragmentupdate(self, s, len);
                break;
            case CAPSETTYPE_SURFACE_COMMANDS:
                xrdp_caps_process_surface_cmds(self, s, len);
                break;
            case CAPSSETTYPE_BITMAP_CODECS:
                xrdp_caps_process_codecs(self, s, len);
                break;
            case CAPSTYPE_FRAME_ACKNOWLEDGE:
                xrdp_caps_process_frame_ack(self, s, len);
                break;
            default:
                g_writeln("unknown in xrdp_caps_process_confirm_active %d", type);
                break;
        }

        s->p = p + len + 4;
    }

    if (self->client_info.no_orders_supported &&
        (self->client_info.offscreen_support_level != 0))
    {
        g_writeln("xrdp_caps_process_confirm_active: not enough orders "
                  "supported by client, client wants off screen bitmap but "
                  "offscreen bitmaps disabled");
        self->client_info.offscreen_support_level = 0;
        self->client_info.offscreen_cache_size = 0;
        self->client_info.offscreen_cache_entries = 0;
    }

    DEBUG(("out xrdp_caps_process_confirm_active"));
    return 0;
}