Fixed invalid package size allocation and calculation in cliprdr_process_format_list_...
authorArmin Novak <anovak@thinstuff.com>
Fri, 9 Aug 2013 14:23:00 +0000 (16:23 +0200)
committerArmin Novak <anovak@thinstuff.com>
Fri, 9 Aug 2013 14:23:00 +0000 (16:23 +0200)
Enabled and fixed error handling in cliprdr_process_format_list_response

channels/cliprdr/client/cliprdr_format.c

index 023bbf8..fb6bef9 100644 (file)
@@ -87,14 +87,15 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
                        if (!cliprdr->use_long_format_names)
                                name_length = 32;
                        
-                       Stream_EnsureRemainingCapacity(body, Stream_Capacity(body) + 4 + name_length);
+                       Stream_EnsureRemainingCapacity(body, 4 + name_length);
 
                        Stream_Write_UINT32(body, cb_event->formats[i]);
                        Stream_Write(body, name, name_length);
                }
                                
-               s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Capacity(body));
-               Stream_Write(s, Stream_Buffer(body), Stream_Capacity(body));
+               Stream_SealLength(body);
+               s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Length(body));
+               Stream_Write(s, Stream_Buffer(body), Stream_Length(body));
                Stream_Free(body, TRUE);
        }
 
@@ -291,15 +292,15 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
 void cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags)
 {
        /* where is this documented? */
-#if 0
        wMessage* event;
 
        if ((msgFlags & CB_RESPONSE_FAIL) != 0)
        {
-               event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_MONITOR_READY, NULL, NULL);
+               /* In case of an error the clipboard will cease to operate.
+                * Post this event to reenable the plugin. */
+               event = freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_MonitorReady, NULL, NULL);
                svc_plugin_send_event((rdpSvcPlugin*) cliprdr, event);
        }
-#endif
 }
 
 void cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags)