Allocate buffer to allow large reads, rather than force all reads down to 4K.

This commit is contained in:
Michael Jumper 2013-12-17 14:17:56 -08:00
parent c38b687ab6
commit 7ee813bbfd

View File

@ -139,7 +139,7 @@ void guac_rdpdr_fs_process_read(guac_rdpdr_device* device,
UINT32 length; UINT32 length;
UINT64 offset; UINT64 offset;
char buffer[4096]; char* buffer;
int bytes_read; int bytes_read;
wStream* output_stream; wStream* output_stream;
@ -148,13 +148,12 @@ void guac_rdpdr_fs_process_read(guac_rdpdr_device* device,
Stream_Read_UINT32(input_stream, length); Stream_Read_UINT32(input_stream, length);
Stream_Read_UINT64(input_stream, offset); Stream_Read_UINT64(input_stream, offset);
/* Allocate buffer */
buffer = malloc(length);
GUAC_RDP_DEBUG(2, "[file_id=%i] length=%i, offset=%" PRIu64, GUAC_RDP_DEBUG(2, "[file_id=%i] length=%i, offset=%" PRIu64,
file_id, length, (uint64_t) offset); file_id, length, (uint64_t) offset);
/* Read no more than size of buffer */
if (length > sizeof(buffer))
length = sizeof(buffer);
/* Attempt read */ /* Attempt read */
bytes_read = guac_rdp_fs_read((guac_rdp_fs*) device->data, file_id, offset, bytes_read = guac_rdp_fs_read((guac_rdp_fs*) device->data, file_id, offset,
buffer, length); buffer, length);
@ -175,6 +174,7 @@ void guac_rdpdr_fs_process_read(guac_rdpdr_device* device,
} }
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
free(buffer);
} }