libfreerdp-core: fix handling of SSL_CERT_NOT_ON_SERVER

This commit is contained in:
Marc-André Moreau 2013-04-12 18:03:56 -04:00
parent d776a2d4ea
commit 073c6fb983
4 changed files with 27 additions and 16 deletions

View File

@ -308,7 +308,7 @@ BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, BYTE* buffer, siz
line = strtok_s((char*) buffer, "\r\n", &context); line = strtok_s((char*) buffer, "\r\n", &context);
while (line != NULL) while (line)
{ {
length = strlen(line); length = strlen(line);
@ -458,8 +458,7 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, char* name)
if (file_size < 1) if (file_size < 1)
return FALSE; return FALSE;
buffer = (BYTE*) malloc(file_size); buffer = (BYTE*) malloc(file_size + 2);
read_size = fread(buffer, file_size, 1, fp); read_size = fread(buffer, file_size, 1, fp);
if (!read_size) if (!read_size)
@ -475,6 +474,9 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, char* name)
return FALSE; return FALSE;
} }
buffer[file_size] = '\0';
buffer[file_size + 1] = '\0';
return freerdp_client_parse_rdp_file_buffer(file, buffer, file_size); return freerdp_client_parse_rdp_file_buffer(file, buffer, file_size);
} }
@ -497,7 +499,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->ServerPort) if (~file->ServerPort)
settings->ServerPort = file->ServerPort; settings->ServerPort = file->ServerPort;
if (~((size_t) file->FullAddress)) if (~((size_t) file->FullAddress))
settings->ServerHostname = file->FullAddress; settings->ServerHostname = _strdup(file->FullAddress);
if (~file->DesktopWidth) if (~file->DesktopWidth)
settings->DesktopWidth = file->DesktopWidth; settings->DesktopWidth = file->DesktopWidth;
if (~file->DesktopHeight) if (~file->DesktopHeight)
@ -513,9 +515,9 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->EnableCredSSPSupport) if (~file->EnableCredSSPSupport)
settings->NlaSecurity = file->EnableCredSSPSupport; settings->NlaSecurity = file->EnableCredSSPSupport;
if (~((size_t) file->AlternateShell)) if (~((size_t) file->AlternateShell))
settings->AlternateShell = file->AlternateShell; settings->AlternateShell = _strdup(file->AlternateShell);
if (~((size_t) file->ShellWorkingDirectory)) if (~((size_t) file->ShellWorkingDirectory))
settings->ShellWorkingDirectory = file->ShellWorkingDirectory; settings->ShellWorkingDirectory = _strdup(file->ShellWorkingDirectory);
if (~((size_t) file->LoadBalanceInfo)) if (~((size_t) file->LoadBalanceInfo))
{ {
@ -546,7 +548,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
} }
if (~((size_t) file->GatewayHostname)) if (~((size_t) file->GatewayHostname))
settings->GatewayHostname = file->GatewayHostname; settings->GatewayHostname = _strdup(file->GatewayHostname);
if (~file->GatewayUsageMethod) if (~file->GatewayUsageMethod)
settings->GatewayUsageMethod = TRUE; settings->GatewayUsageMethod = TRUE;
if (~file->PromptCredentialOnce) if (~file->PromptCredentialOnce)
@ -555,17 +557,17 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->RemoteApplicationMode) if (~file->RemoteApplicationMode)
settings->RemoteApplicationMode = file->RemoteApplicationMode; settings->RemoteApplicationMode = file->RemoteApplicationMode;
if (~((size_t) file->RemoteApplicationProgram)) if (~((size_t) file->RemoteApplicationProgram))
settings->RemoteApplicationProgram = file->RemoteApplicationProgram; settings->RemoteApplicationProgram = _strdup(file->RemoteApplicationProgram);
if (~((size_t) file->RemoteApplicationName)) if (~((size_t) file->RemoteApplicationName))
settings->RemoteApplicationName = file->RemoteApplicationName; settings->RemoteApplicationName = _strdup(file->RemoteApplicationName);
if (~((size_t) file->RemoteApplicationIcon)) if (~((size_t) file->RemoteApplicationIcon))
settings->RemoteApplicationIcon = file->RemoteApplicationIcon; settings->RemoteApplicationIcon = _strdup(file->RemoteApplicationIcon);
if (~((size_t) file->RemoteApplicationFile)) if (~((size_t) file->RemoteApplicationFile))
settings->RemoteApplicationFile = file->RemoteApplicationFile; settings->RemoteApplicationFile = _strdup(file->RemoteApplicationFile);
if (~((size_t) file->RemoteApplicationGuid)) if (~((size_t) file->RemoteApplicationGuid))
settings->RemoteApplicationGuid = file->RemoteApplicationGuid; settings->RemoteApplicationGuid = _strdup(file->RemoteApplicationGuid);
if (~((size_t) file->RemoteApplicationCmdLine)) if (~((size_t) file->RemoteApplicationCmdLine))
settings->RemoteApplicationCmdLine = file->RemoteApplicationCmdLine; settings->RemoteApplicationCmdLine = _strdup(file->RemoteApplicationCmdLine);
if (~file->SpanMonitors) if (~file->SpanMonitors)
settings->SpanMonitors = file->SpanMonitors; settings->SpanMonitors = file->SpanMonitors;

View File

@ -563,6 +563,7 @@ BOOL nego_read_request(rdpNego* nego, wStream* s)
BYTE type; BYTE type;
tpkt_read_header(s); tpkt_read_header(s);
if (!tpdu_read_connection_request(s, &li)) if (!tpdu_read_connection_request(s, &li))
return FALSE; return FALSE;
@ -671,7 +672,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
DEBUG_NEGO("requested_protocols: %d", nego->requested_protocols); DEBUG_NEGO("requested_protocols: %d", nego->requested_protocols);
if (nego->requested_protocols > PROTOCOL_RDP) if ((nego->requested_protocols > PROTOCOL_RDP) || (nego->sendNegoData))
{ {
/* RDP_NEG_DATA must be present for TLS and NLA */ /* RDP_NEG_DATA must be present for TLS and NLA */
stream_write_BYTE(s, TYPE_RDP_NEG_REQ); stream_write_BYTE(s, TYPE_RDP_NEG_REQ);
@ -764,18 +765,24 @@ void nego_process_negotiation_failure(rdpNego* nego, wStream* s)
case SSL_REQUIRED_BY_SERVER: case SSL_REQUIRED_BY_SERVER:
DEBUG_NEGO("Error: SSL_REQUIRED_BY_SERVER"); DEBUG_NEGO("Error: SSL_REQUIRED_BY_SERVER");
break; break;
case SSL_NOT_ALLOWED_BY_SERVER: case SSL_NOT_ALLOWED_BY_SERVER:
DEBUG_NEGO("Error: SSL_NOT_ALLOWED_BY_SERVER"); DEBUG_NEGO("Error: SSL_NOT_ALLOWED_BY_SERVER");
break; break;
case SSL_CERT_NOT_ON_SERVER: case SSL_CERT_NOT_ON_SERVER:
DEBUG_NEGO("Error: SSL_CERT_NOT_ON_SERVER"); DEBUG_NEGO("Error: SSL_CERT_NOT_ON_SERVER");
nego->sendNegoData = TRUE;
break; break;
case INCONSISTENT_FLAGS: case INCONSISTENT_FLAGS:
DEBUG_NEGO("Error: INCONSISTENT_FLAGS"); DEBUG_NEGO("Error: INCONSISTENT_FLAGS");
break; break;
case HYBRID_REQUIRED_BY_SERVER: case HYBRID_REQUIRED_BY_SERVER:
DEBUG_NEGO("Error: HYBRID_REQUIRED_BY_SERVER"); DEBUG_NEGO("Error: HYBRID_REQUIRED_BY_SERVER");
break; break;
default: default:
DEBUG_NEGO("Error: Unknown protocol security error %d", failureCode); DEBUG_NEGO("Error: Unknown protocol security error %d", failureCode);
break; break;

View File

@ -100,6 +100,7 @@ struct rdp_nego
BOOL security_connected; BOOL security_connected;
UINT32 cookie_max_length; UINT32 cookie_max_length;
BOOL sendNegoData;
UINT32 selected_protocol; UINT32 selected_protocol;
UINT32 requested_protocols; UINT32 requested_protocols;
BOOL NegotiateSecurityLayer; BOOL NegotiateSecurityLayer;

View File

@ -454,6 +454,7 @@ void freerdp_settings_free(rdpSettings* settings)
free(settings->ConfigPath); free(settings->ConfigPath);
free(settings->CurrentPath); free(settings->CurrentPath);
free(settings->HomePath); free(settings->HomePath);
free(settings->LoadBalanceInfo);
freerdp_device_collection_free(settings); freerdp_device_collection_free(settings);
freerdp_static_channel_collection_free(settings); freerdp_static_channel_collection_free(settings);
freerdp_dynamic_channel_collection_free(settings); freerdp_dynamic_channel_collection_free(settings);