Add ffunction for retrieving a file by file ID safely. Migrate to new function.
This commit is contained in:
parent
dd1761790a
commit
3217b97f26
@ -422,3 +422,16 @@ int guac_rdpdr_fs_convert_path(const char* parent, const char* rel_path, char* a
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guac_rdpdr_fs_file* guac_rdpdr_fs_get_file(guac_rdpdr_device* device,
|
||||||
|
int file_id) {
|
||||||
|
|
||||||
|
/* Validate ID */
|
||||||
|
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
||||||
|
if (file_id < 0 || file_id >= GUAC_RDPDR_FS_MAX_FILES)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Return file at given ID */
|
||||||
|
return &(data->files[file_id]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -258,5 +258,11 @@ int guac_rdpdr_fs_convert_path(const char* parent, const char* rel_path, char* a
|
|||||||
*/
|
*/
|
||||||
const char* guac_rdpdr_fs_read_dir(guac_rdpdr_device* device, int file_id);
|
const char* guac_rdpdr_fs_read_dir(guac_rdpdr_device* device, int file_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the file having the given ID, or NULL if no such file exists.
|
||||||
|
*/
|
||||||
|
guac_rdpdr_fs_file* guac_rdpdr_fs_get_file(guac_rdpdr_device* device,
|
||||||
|
int file_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -292,13 +292,17 @@ void guac_rdpdr_fs_process_query_directory(guac_rdpdr_device* device, wStream* i
|
|||||||
|
|
||||||
wStream* output_stream;
|
wStream* output_stream;
|
||||||
|
|
||||||
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
guac_rdpdr_fs_file* file;
|
||||||
guac_rdpdr_fs_file* file = &(data->files[file_id]);
|
|
||||||
int fs_information_class, initial_query;
|
int fs_information_class, initial_query;
|
||||||
int path_length;
|
int path_length;
|
||||||
|
|
||||||
const char* entry_name;
|
const char* entry_name;
|
||||||
|
|
||||||
|
/* Get file */
|
||||||
|
file = guac_rdpdr_fs_get_file(device, file_id);
|
||||||
|
if (file == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Read main header */
|
/* Read main header */
|
||||||
Stream_Read_UINT32(input_stream, fs_information_class);
|
Stream_Read_UINT32(input_stream, fs_information_class);
|
||||||
Stream_Read_UINT8(input_stream, initial_query);
|
Stream_Read_UINT8(input_stream, initial_query);
|
||||||
|
@ -63,8 +63,7 @@ void guac_rdpdr_fs_process_query_full_directory_info(guac_rdpdr_device* device,
|
|||||||
void guac_rdpdr_fs_process_query_both_directory_info(guac_rdpdr_device* device,
|
void guac_rdpdr_fs_process_query_both_directory_info(guac_rdpdr_device* device,
|
||||||
const char* entry_name, int file_id, int completion_id) {
|
const char* entry_name, int file_id, int completion_id) {
|
||||||
|
|
||||||
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
guac_rdpdr_fs_file* file;
|
||||||
guac_rdpdr_fs_file* file = &(data->files[file_id]);
|
|
||||||
|
|
||||||
wStream* output_stream = Stream_New(NULL, 256);
|
wStream* output_stream = Stream_New(NULL, 256);
|
||||||
int length = guac_utf8_strlen(entry_name);
|
int length = guac_utf8_strlen(entry_name);
|
||||||
@ -73,6 +72,11 @@ void guac_rdpdr_fs_process_query_both_directory_info(guac_rdpdr_device* device,
|
|||||||
unsigned char utf16_entry_name[256];
|
unsigned char utf16_entry_name[256];
|
||||||
guac_rdp_utf8_to_utf16((const unsigned char*) entry_name, (char*) utf16_entry_name, length);
|
guac_rdp_utf8_to_utf16((const unsigned char*) entry_name, (char*) utf16_entry_name, length);
|
||||||
|
|
||||||
|
/* Get file */
|
||||||
|
file = guac_rdpdr_fs_get_file(device, file_id);
|
||||||
|
if (file == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Write header */
|
/* Write header */
|
||||||
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
|
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
|
||||||
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
|
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
|
||||||
|
@ -56,8 +56,12 @@ void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream*
|
|||||||
int file_id, int completion_id) {
|
int file_id, int completion_id) {
|
||||||
|
|
||||||
wStream* output_stream = Stream_New(NULL, 60);
|
wStream* output_stream = Stream_New(NULL, 60);
|
||||||
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
guac_rdpdr_fs_file* file;
|
||||||
guac_rdpdr_fs_file* file = &(data->files[file_id]);
|
|
||||||
|
/* Get file */
|
||||||
|
file = guac_rdpdr_fs_get_file(device, file_id);
|
||||||
|
if (file == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Write header */
|
/* Write header */
|
||||||
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
|
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
|
||||||
@ -85,10 +89,14 @@ void guac_rdpdr_fs_process_query_standard_info(guac_rdpdr_device* device, wStrea
|
|||||||
int file_id, int completion_id) {
|
int file_id, int completion_id) {
|
||||||
|
|
||||||
wStream* output_stream = Stream_New(NULL, 60);
|
wStream* output_stream = Stream_New(NULL, 60);
|
||||||
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
guac_rdpdr_fs_file* file;
|
||||||
guac_rdpdr_fs_file* file = &(data->files[file_id]);
|
|
||||||
|
|
||||||
BOOL is_directory = FALSE;
|
BOOL is_directory = FALSE;
|
||||||
|
|
||||||
|
/* Get file */
|
||||||
|
file = guac_rdpdr_fs_get_file(device, file_id);
|
||||||
|
if (file == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (file->attributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file->attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
is_directory = TRUE;
|
is_directory = TRUE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user