diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c index 24a92d37..3b5d2232 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c @@ -60,11 +60,11 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path) { /* If no files available, return too many open */ if (data->open_files >= GUAC_RDPDR_FS_MAX_FILES) - return -1; + return GUAC_RDPDR_FS_ENFILE; /* If path is empty, the file does not exist */ if (path[0] == '\0') - return -2; + return GUAC_RDPDR_FS_ENOENT; file->type = GUAC_RDPDR_FS_FILE; /* STUB */ diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h index 8d0073a0..019b6c92 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h @@ -60,6 +60,16 @@ */ #define GUAC_RDPDR_FS_MAX_FILES 128 +/** + * Error code returned when no more file IDs can be allocated. + */ +#define GUAC_RDPDR_FS_ENFILE -1 + +/** + * Error code returned with no such file exists. + */ +#define GUAC_RDPDR_FS_ENOENT -2 + /* * Information constants. */ diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c index 1fadb4b3..2ba5f39d 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c @@ -89,19 +89,23 @@ void guac_rdpdr_fs_process_create(guac_rdpdr_device* device, Stream_Write_UINT32(output_stream, completion_id); /* If no file IDs available, notify server */ - if (file_id == -1) { + if (file_id == GUAC_RDPDR_FS_ENFILE) { guac_client_log_error(device->rdpdr->client, "File open refused - too many open files"); Stream_Write_UINT32(output_stream, STATUS_TOO_MANY_OPENED_FILES); Stream_Write_UINT32(output_stream, 0); /* fileId */ Stream_Write_UINT8(output_stream, 0); /* information */ } - else if (file_id == -2) { + + /* If file does not exist, notify server */ + else if (file_id == GUAC_RDPDR_FS_ENOENT) { guac_client_log_error(device->rdpdr->client, "File open refused - does not exist: \"%s\"", path); Stream_Write_UINT32(output_stream, STATUS_NO_SUCH_FILE); Stream_Write_UINT32(output_stream, 0); /* fileId */ Stream_Write_UINT8(output_stream, 0); /* information */ } + + /* Otherwise, open succeeded */ else { guac_client_log_info(device->rdpdr->client, "Opened file \"%s\" ... new id=%i", path, file_id);