diff options
Diffstat (limited to 'client/common')
-rw-r--r-- | client/common/CMakeLists.txt | 28 | ||||
-rw-r--r-- | client/common/client.c | 15 | ||||
-rw-r--r-- | client/common/client_cliprdr_file.c | 50 | ||||
-rw-r--r-- | client/common/cmdline.c | 87 | ||||
-rw-r--r-- | client/common/cmdline.h | 2 | ||||
-rw-r--r-- | client/common/file.c | 17 | ||||
-rw-r--r-- | client/common/man/generate_argument_docbook.c | 1 | ||||
-rw-r--r-- | client/common/test/TestClientCmdLine.c | 4 |
8 files changed, 110 insertions, 94 deletions
diff --git a/client/common/CMakeLists.txt b/client/common/CMakeLists.txt index 6040bf3..1773533 100644 --- a/client/common/CMakeLists.txt +++ b/client/common/CMakeLists.txt @@ -58,30 +58,9 @@ if(WITH_FUSE) add_definitions(-D_FILE_OFFSET_BITS=64) endif() -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32 AND BUILD_SHARED_LIBS) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${FREERDP_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - -list (APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - include_directories(${OPENSSL_INCLUDE_DIR}) -add_library(${MODULE_NAME} ${SRCS}) - -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" SRCS) list(APPEND LIBS freerdp winpr) @@ -94,11 +73,6 @@ install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT FreeRDP-ClientTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Common") if(BUILD_TESTING) diff --git a/client/common/client.c b/client/common/client.c index 9d6ec03..83a5746 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -1574,8 +1574,9 @@ BOOL freerdp_client_send_button_event(rdpClientContext* cctx, BOOL relative, UIN WINPR_ASSERT(cctx); - const BOOL relativeInput = freerdp_client_use_relative_mouse_events(cctx); - if (relative && relativeInput) + const BOOL haveRelative = + freerdp_settings_get_bool(cctx->context.settings, FreeRDP_HasRelativeMouseEvent); + if (relative && haveRelative) { return freerdp_input_send_rel_mouse_event(cctx->context.input, mflags, x, y); } @@ -1585,7 +1586,7 @@ BOOL freerdp_client_send_button_event(rdpClientContext* cctx, BOOL relative, UIN { UINT64 flags = 0; - if (cctx->mouse_grabbed && relativeInput) + if (cctx->mouse_grabbed && freerdp_client_use_relative_mouse_events(cctx)) flags |= AINPUT_FLAGS_HAVE_REL; if (relative) @@ -1630,7 +1631,9 @@ BOOL freerdp_client_send_extended_button_event(rdpClientContext* cctx, BOOL rela BOOL handled = FALSE; WINPR_ASSERT(cctx); - if (relative && freerdp_client_use_relative_mouse_events(cctx)) + const BOOL haveRelative = + freerdp_settings_get_bool(cctx->context.settings, FreeRDP_HasRelativeMouseEvent); + if (relative && haveRelative) { return freerdp_input_send_rel_mouse_event(cctx->context.input, mflags, x, y); } @@ -2147,8 +2150,8 @@ BOOL freerdp_client_use_relative_mouse_events(rdpClientContext* ccontext) const rdpSettings* settings = ccontext->context.settings; const BOOL useRelative = freerdp_settings_get_bool(settings, FreeRDP_MouseUseRelativeMove); const BOOL haveRelative = freerdp_settings_get_bool(settings, FreeRDP_HasRelativeMouseEvent); - BOOL ainput = false; -#if defined(CHANNEL_AINPUT_SERVER) + BOOL ainput = FALSE; +#if defined(CHANNEL_AINPUT_CLIENT) ainput = ccontext->ainput != NULL; #endif diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index 9b3ee22..df9226f 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -353,7 +353,6 @@ static BOOL maybe_clear_fuse_request(const void* key, void* value, void* arg) fuse_reply_err(fuse_request->fuse_req, EIO); HashTable_Remove(file_context->request_table, key); - free(fuse_request); return TRUE; } @@ -505,16 +504,15 @@ static void clear_no_cdi_entry(CliprdrFileContext* file_context) { WINPR_ASSERT(file_context); - if (!file_context->clip_data_entry_without_id) - return; - WINPR_ASSERT(file_context->inode_table); - HashTable_Lock(file_context->inode_table); - clear_entry_selection(file_context->clip_data_entry_without_id); + if (file_context->clip_data_entry_without_id) + { + clear_entry_selection(file_context->clip_data_entry_without_id); - clip_data_entry_free(file_context->clip_data_entry_without_id); - file_context->clip_data_entry_without_id = NULL; + clip_data_entry_free(file_context->clip_data_entry_without_id); + file_context->clip_data_entry_without_id = NULL; + } HashTable_Unlock(file_context->inode_table); } @@ -555,6 +553,7 @@ static UINT prepare_clip_data_entry_with_id(CliprdrFileContext* file_context) { WLog_Print(file_context->log, WLOG_ERROR, "Failed to insert clipDataEntry"); clip_data_entry_free(clip_data_entry); + HashTable_Unlock(file_context->inode_table); return ERROR_INTERNAL_ERROR; } HashTable_Unlock(file_context->inode_table); @@ -748,7 +747,6 @@ static BOOL request_file_size_async(CliprdrFileContext* file_context, CliprdrFus "Failed to send FileContentsRequest for file \"%s\"", fuse_file->filename_with_root); HashTable_Remove(file_context->request_table, (void*)(UINT_PTR)fuse_request->stream_id); - free(fuse_request); return FALSE; } DEBUG_CLIPRDR(file_context->log, "Requested file size for file \"%s\" with stream id %u", @@ -1191,18 +1189,17 @@ static UINT cliprdr_file_context_server_file_contents_response( HashTable_Unlock(file_context->inode_table); return CHANNEL_RC_OK; } - HashTable_Remove(file_context->request_table, - (void*)(UINT_PTR)file_contents_response->streamId); if (!(file_contents_response->common.msgFlags & CB_RESPONSE_OK)) { WLog_Print(file_context->log, WLOG_WARN, "FileContentsRequests for file \"%s\" was unsuccessful", fuse_request->fuse_file->filename); - HashTable_Unlock(file_context->inode_table); fuse_reply_err(fuse_request->fuse_req, EIO); - free(fuse_request); + HashTable_Remove(file_context->request_table, + (void*)(UINT_PTR)file_contents_response->streamId); + HashTable_Unlock(file_context->inode_table); return CHANNEL_RC_OK; } @@ -1213,10 +1210,10 @@ static UINT cliprdr_file_context_server_file_contents_response( WLog_Print(file_context->log, WLOG_WARN, "Received invalid file size for file \"%s\" from the client", fuse_request->fuse_file->filename); - HashTable_Unlock(file_context->inode_table); - fuse_reply_err(fuse_request->fuse_req, EIO); - free(fuse_request); + HashTable_Remove(file_context->request_table, + (void*)(UINT_PTR)file_contents_response->streamId); + HashTable_Unlock(file_context->inode_table); return CHANNEL_RC_OK; } @@ -1258,7 +1255,8 @@ static UINT cliprdr_file_context_server_file_contents_response( break; } - free(fuse_request); + HashTable_Remove(file_context->request_table, + (void*)(UINT_PTR)file_contents_response->streamId); return CHANNEL_RC_OK; } @@ -1806,7 +1804,7 @@ static CliprdrFuseFile* get_parent_directory(CliprdrFileContext* file_context, c static BOOL set_selection_for_clip_data_entry(CliprdrFileContext* file_context, CliprdrFuseClipDataEntry* clip_data_entry, - FILEDESCRIPTORW* files, UINT32 n_files) + const FILEDESCRIPTORW* files, UINT32 n_files) { CliprdrFuseFile* clip_data_dir = NULL; @@ -1826,7 +1824,7 @@ static BOOL set_selection_for_clip_data_entry(CliprdrFileContext* file_context, // NOLINTBEGIN(clang-analyzer-unix.Malloc) HashTable_Insert owns fuse_file for (UINT32 i = 0; i < n_files; ++i) { - FILEDESCRIPTORW* file = &files[i]; + const FILEDESCRIPTORW* file = &files[i]; CliprdrFuseFile* fuse_file = NULL; char* filename = NULL; size_t path_length = 0; @@ -2016,6 +2014,7 @@ BOOL cliprdr_file_context_update_server_data(CliprdrFileContext* file_context, w } HashTable_Unlock(file_context->inode_table); + free(files); return TRUE; #else return FALSE; @@ -2417,9 +2416,16 @@ CliprdrFileContext* cliprdr_file_context_new(void* context) if (!file->inode_table || !file->clip_data_table || !file->request_table) goto fail; - wObject* ctobj = HashTable_ValueObject(file->clip_data_table); - WINPR_ASSERT(ctobj); - ctobj->fnObjectFree = clip_data_entry_free; + { + wObject* ctobj = HashTable_ValueObject(file->request_table); + WINPR_ASSERT(ctobj); + ctobj->fnObjectFree = free; + } + { + wObject* ctobj = HashTable_ValueObject(file->clip_data_table); + WINPR_ASSERT(ctobj); + ctobj->fnObjectFree = clip_data_entry_free; + } file->root_dir = fuse_file_new_root(file); if (!file->root_dir) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 2ce693b..01d5b37 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -214,18 +214,20 @@ static BOOL freerdp_client_add_drive(rdpSettings* settings, const char* path, co if (!path) goto fail; - else + { BOOL isSpecial = FALSE; BOOL isPath = freerdp_path_valid(path, &isSpecial); if (!isPath && !isSpecial) + { + WLog_WARN(TAG, "Invalid drive to redirect: '%s' does not exist, skipping.", path); + freerdp_device_free(device); + } + else if (!freerdp_device_collection_add(settings, device)) goto fail; } - if (!freerdp_device_collection_add(settings, device)) - goto fail; - return TRUE; fail: @@ -370,7 +372,7 @@ static char* print_token(char* text, size_t start_offset, size_t* current, size_ const size_t tlen = strnlen(text, limit); size_t len = tlen; const SSIZE_T force_at = forced_newline_at(text, len, limit - *current, force_newline); - BOOL isForce = (force_at > 0); + BOOL isForce = (force_at >= 0); if (isForce) len = MIN(len, (size_t)force_at); @@ -394,7 +396,7 @@ static char* print_token(char* text, size_t start_offset, size_t* current, size_ printf("\n"); *current = 0; - const size_t offset = len + (isForce ? 1 : 0); + const size_t offset = len + ((isForce && (force_at == 0)) ? 1 : 0); return &text[offset]; } @@ -411,8 +413,10 @@ static size_t print_optionals(const char* text, size_t start_offset, size_t curr char* str = _strdup(text); char* cur = str; - while ((cur = print_token(cur, start_offset + 1, ¤t, limit, "[], ", "\r\n")) != NULL) - ; + do + { + cur = print_token(cur, start_offset + 1, ¤t, limit, "[], ", "\r\n"); + } while (cur != NULL); free(str); return current; @@ -424,8 +428,10 @@ static size_t print_description(const char* text, size_t start_offset, size_t cu char* str = _strdup(text); char* cur = str; - while ((cur = print_token(cur, start_offset, ¤t, limit, " ", "\r\n")) != NULL) - ; + do + { + cur = print_token(cur, start_offset, ¤t, limit, " ", "\r\n"); + } while (cur != NULL); free(str); current += (size_t)printf("\n"); @@ -895,7 +901,10 @@ static BOOL read_pem_file(rdpSettings* settings, FreeRDP_Settings_Keys_String id size_t length = 0; char* pem = crypto_read_pem(file, &length); if (!pem || (length == 0)) + { + free(pem); return FALSE; + } BOOL rc = freerdp_settings_set_string_len(settings, id, pem, length); free(pem); @@ -1167,6 +1176,14 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A static BOOL freerdp_parse_username_ptr(const char* username, const char** user, size_t* userlen, const char** domain, size_t* domainlen) { + WINPR_ASSERT(user); + WINPR_ASSERT(userlen); + WINPR_ASSERT(domain); + WINPR_ASSERT(domainlen); + + if (!username) + return FALSE; + const char* p = strchr(username, '\\'); *user = NULL; @@ -1184,7 +1201,7 @@ static BOOL freerdp_parse_username_ptr(const char* username, const char** user, *domain = username; *domainlen = length; } - else if (username) + else { /* Do not break up the name for '@'; both credSSP and the * ClientInfo PDU expect 'user@corp.net' to be transmitted @@ -1193,8 +1210,6 @@ static BOOL freerdp_parse_username_ptr(const char* username, const char** user, *user = username; *userlen = strlen(username); } - else - return FALSE; return TRUE; } @@ -1382,24 +1397,27 @@ BOOL freerdp_set_connection_type(rdpSettings* settings, UINT32 type) static UINT32 freerdp_get_keyboard_layout_for_type(const char* name, DWORD type) { + UINT32 res = 0; size_t count = 0; RDP_KEYBOARD_LAYOUT* layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, &count); if (!layouts || (count == 0)) - return FALSE; + goto fail; for (size_t x = 0; x < count; x++) { const RDP_KEYBOARD_LAYOUT* layout = &layouts[x]; if (option_equals(layout->name, name)) { - return layout->code; + res = layout->code; + break; } } +fail: freerdp_keyboard_layouts_free(layouts, count); - return 0; + return res; } static UINT32 freerdp_map_keyboard_layout_name_to_id(const char* name) @@ -2308,7 +2326,8 @@ static int parse_codec_cache_options(rdpSettings* settings, const COMMAND_LINE_A } else if (option_equals(arg->Value, "nsc")) { - freerdp_settings_set_bool(settings, FreeRDP_NSCodec, TRUE); + if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, TRUE)) + return COMMAND_LINE_ERROR; } #if defined(WITH_JPEG) @@ -2325,6 +2344,7 @@ static int parse_codec_cache_options(rdpSettings* settings, const COMMAND_LINE_A } #endif + return 0; } #endif @@ -3576,18 +3596,18 @@ static int parse_app_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_ struct app_map { const char* name; - FreeRDP_Settings_Keys_String id; + SSIZE_T id; int (*fkt)(rdpSettings* settings, const char* value); }; - const struct app_map amap[] = { - { "program:", FreeRDP_RemoteApplicationProgram, parse_app_option_program }, - { "workdir:", FreeRDP_RemoteApplicationWorkingDir, NULL }, - { "name:", FreeRDP_RemoteApplicationName, NULL }, - { "icon:", FreeRDP_RemoteApplicationIcon, NULL }, - { "cmd:", FreeRDP_RemoteApplicationCmdLine, NULL }, - { "file:", FreeRDP_RemoteApplicationFile, NULL }, - { "guid:", FreeRDP_RemoteApplicationGuid, NULL }, - }; + const struct app_map amap[] = { { "program:", FreeRDP_RemoteApplicationProgram, + parse_app_option_program }, + { "workdir:", FreeRDP_RemoteApplicationWorkingDir, NULL }, + { "name:", FreeRDP_RemoteApplicationName, NULL }, + { "icon:", FreeRDP_RemoteApplicationIcon, NULL }, + { "cmd:", FreeRDP_RemoteApplicationCmdLine, NULL }, + { "file:", FreeRDP_RemoteApplicationFile, NULL }, + { "guid:", FreeRDP_RemoteApplicationGuid, NULL }, + { "hidef:", FreeRDP_HiDefRemoteApp, NULL } }; for (size_t x = 0; x < count; x++) { BOOL handled = FALSE; @@ -3601,8 +3621,12 @@ static int parse_app_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_ const char* xval = &val[strlen(cur->name)]; if (cur->fkt) rc = cur->fkt(settings, xval); - else if (!freerdp_settings_set_string(settings, cur->id, xval)) - rc = COMMAND_LINE_ERROR_MEMORY; + else + { + const char* name = freerdp_settings_get_name_for_key(cur->id); + if (!freerdp_settings_set_value_for_name(settings, name, xval)) + rc = COMMAND_LINE_ERROR_MEMORY; + } handled = TRUE; break; @@ -4749,11 +4773,14 @@ static int freerdp_client_settings_parse_command_line_arguments_int( "vs-debug") || !freerdp_settings_set_string(settings, FreeRDP_ServerHostname, "localhost") || !freerdp_settings_set_string(settings, FreeRDP_AuthenticationPackageList, "ntlm") || + !freerdp_settings_set_string(settings, FreeRDP_ClientAddress, "0.0.0.0") || !freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, FALSE) || !freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE) || !freerdp_settings_set_bool(settings, FreeRDP_ConnectChildSession, TRUE) || !freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, TRUE) || - !freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel, 0)) + !freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel, 0) || + !freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, TRUE) || + !freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, CONNECTION_TYPE_LAN)) return COMMAND_LINE_ERROR_MEMORY; } #endif diff --git a/client/common/cmdline.h b/client/common/cmdline.h index 8186cc6..3afddb1 100644 --- a/client/common/cmdline.h +++ b/client/common/cmdline.h @@ -34,7 +34,7 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = { "desktop composition" }, { "app", COMMAND_LINE_VALUE_REQUIRED, "program:[<path>|<||alias>],cmd:<command>,file:<filename>,guid:<guid>,icon:<filename>,name:<" - "name>,workdir:<directory>", + "name>,workdir:<directory>,hidef:[on|off]", NULL, NULL, -1, NULL, "Remote application program" }, #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE) { "app-cmd", COMMAND_LINE_VALUE_REQUIRED, "<parameters>", NULL, NULL, -1, NULL, diff --git a/client/common/file.c b/client/common/file.c index 760c62e..a72ab41 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -1309,7 +1309,7 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSett file->RedirectComPorts = (freerdp_settings_get_bool(settings, FreeRDP_RedirectSerialPorts) || freerdp_settings_get_bool(settings, FreeRDP_RedirectParallelPorts)); file->RedirectLocation = - freerdp_dynamic_channel_collection_find(settings, LOCATION_DVC_CHANNEL_NAME) ? TRUE : FALSE; + freerdp_dynamic_channel_collection_find(settings, LOCATION_CHANNEL_NAME) ? TRUE : FALSE; if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) || !FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob) || !FILE_POPULATE_STRING(&file->KdcProxyName, settings, FreeRDP_KerberosKdcUrl)) @@ -2296,13 +2296,18 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett return FALSE; } - if (~file->RedirectLocation) + if (~file->RedirectLocation && file->RedirectLocation != 0) { size_t count = 0; - char** str = - CommandLineParseCommaSeparatedValuesEx(LOCATION_DVC_CHANNEL_NAME, NULL, &count); - const BOOL rc = freerdp_client_add_dynamic_channel(settings, count, str); - free(str); + union + { + void* pv; + char** str; + const char** cstr; + } cnv; + cnv.str = CommandLineParseCommaSeparatedValuesEx(LOCATION_CHANNEL_NAME, NULL, &count); + const BOOL rc = freerdp_client_add_dynamic_channel(settings, count, cnv.cstr); + free(cnv.pv); if (!rc) return FALSE; } diff --git a/client/common/man/generate_argument_docbook.c b/client/common/man/generate_argument_docbook.c index 156d809..a591dd0 100644 --- a/client/common/man/generate_argument_docbook.c +++ b/client/common/man/generate_argument_docbook.c @@ -15,6 +15,7 @@ static char* resize(char** buffer, size_t* size, size_t increment) fprintf(stderr, "Could not reallocate string buffer from %" PRIuz " to %" PRIuz " bytes.\n", *size, nsize); free(*buffer); + return NULL; } memset(&tmp[*size], '\0', increment); *size = nsize; diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c index 2ce0c47..ba0cfe6 100644 --- a/client/common/test/TestClientCmdLine.c +++ b/client/common/test/TestClientCmdLine.c @@ -191,11 +191,11 @@ static const test tests[] = { check_settings_smartcard_no_redirection, { "testfreerdp", "/list:monitor", 0 }, { { 0 } } }, - { COMMAND_LINE_ERROR, + { 0, check_settings_smartcard_no_redirection, { "testfreerdp", "/sound", "/drive:media:" DRIVE_REDIRECT_PATH, "/v:test.freerdp.com", 0 }, { { 0 } } }, - { COMMAND_LINE_ERROR, + { 0, check_settings_smartcard_no_redirection, { "testfreerdp", "/sound", "/drive:media,/foo/bar/blabla", "/v:test.freerdp.com", 0 }, { { 0 } } }, |