Github user mike-jumper commented on a diff in the pull request: https://github.com/apache/guacamole-server/pull/154#discussion_r199683587 --- Diff: src/protocols/rdp/guac_rdpdr/rdpdr_messages.c --- @@ -122,20 +124,28 @@ static void guac_rdpdr_send_client_capability(guac_rdpdrPlugin* rdpdr) { static void guac_rdpdr_send_client_device_list_announce_request(guac_rdpdrPlugin* rdpdr) { - int i; - wStream* output_stream = Stream_New(NULL, 256); + /* Calculate number of bytes needed for the stream */ + int streamBytes = 16; + for (int i=0; i < rdpdr->devices_registered; i++) + streamBytes += rdpdr->devices[i].device_announce_len; + + /* Allocate the stream */ + wStream* output_stream = Stream_New(NULL, streamBytes); /* Write header */ Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICELIST_ANNOUNCE); - /* List devices */ + /* Get the stream for each of the devices. */ Stream_Write_UINT32(output_stream, rdpdr->devices_registered); - for (i=0; i<rdpdr->devices_registered; i++) { - guac_rdpdr_device* device = &(rdpdr->devices[i]); - device->announce_handler(device, output_stream, i); + for (int i=0; i<rdpdr->devices_registered; i++) { + + Stream_Copy(output_stream, rdpdr->devices[i].device_announce, --- End diff -- ...am reverting c30fd7a first, though. Writing the raw data structure is a bit too scary, especially since it only contains a pointer to the desired buffer. It shouldn't work, and I'm not sure what I'd do if it _did_ work. ;)
---