mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
@@ -783,6 +783,7 @@ extern "C"
|
||||
* in case of an error.
|
||||
* @since version 3.16.0
|
||||
*/
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
FREERDP_API char* freerdp_settings_serialize(const rdpSettings* settings, BOOL pretty,
|
||||
size_t* plength);
|
||||
|
||||
|
||||
@@ -953,7 +953,17 @@ static BOOL arm_fill_gateway_parameters(rdpArm* arm, const char* message, size_t
|
||||
WINPR_JSON* json = WINPR_JSON_ParseWithLength(message, len);
|
||||
BOOL status = FALSE;
|
||||
if (!json)
|
||||
{
|
||||
WLog_Print(arm->log, WLOG_ERROR, "Response data is not valid JSON");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (WLog_IsLevelActive(arm->log, WLOG_DEBUG))
|
||||
{
|
||||
char* str = WINPR_JSON_PrintUnformatted(json);
|
||||
WLog_Print(arm->log, WLOG_DEBUG, "Got HTTP Response data: %s", str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
rdpSettings* settings = arm->context->settings;
|
||||
WINPR_JSON* gwurl = WINPR_JSON_GetObjectItemCaseSensitive(json, "gatewayLocationPreWebSocket");
|
||||
@@ -1031,11 +1041,14 @@ fail:
|
||||
static BOOL arm_handle_request_ok(rdpArm* arm, const HttpResponse* response)
|
||||
{
|
||||
const size_t len = http_response_get_body_length(response);
|
||||
const char* msg = (const char*)http_response_get_body(response);
|
||||
if (strnlen(msg, len + 1) > len)
|
||||
const char* msg = http_response_get_body(response);
|
||||
const size_t alen = strnlen(msg, len + 1);
|
||||
if (alen > len)
|
||||
{
|
||||
WLog_Print(arm->log, WLOG_ERROR, "Got HTTP Response data with invalid termination");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WLog_Print(arm->log, WLOG_DEBUG, "Got HTTP Response data: %s", msg);
|
||||
return arm_fill_gateway_parameters(arm, msg, len);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ struct s_http_response
|
||||
const char* SecWebsocketAccept;
|
||||
|
||||
size_t BodyLength;
|
||||
BYTE* BodyContent;
|
||||
char* BodyContent;
|
||||
|
||||
wHashTable* Authenticates;
|
||||
wHashTable* SetCookie;
|
||||
@@ -1303,7 +1303,7 @@ static BOOL http_response_recv_body(rdpTls* tls, HttpResponse* response, BOOL re
|
||||
} while (ctx.state != ChunkStateEnd);
|
||||
response->BodyLength = WINPR_ASSERTING_INT_CAST(uint32_t, full_len);
|
||||
if (response->BodyLength > 0)
|
||||
response->BodyContent = &(Stream_Buffer(response->data))[payloadOffset];
|
||||
response->BodyContent = &(Stream_BufferAs(response->data, char))[payloadOffset];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1339,7 +1339,7 @@ static BOOL http_response_recv_body(rdpTls* tls, HttpResponse* response, BOOL re
|
||||
}
|
||||
|
||||
if (response->BodyLength > 0)
|
||||
response->BodyContent = &(Stream_Buffer(response->data))[payloadOffset];
|
||||
response->BodyContent = &(Stream_BufferAs(response->data, char))[payloadOffset];
|
||||
|
||||
if (bodyLength != response->BodyLength)
|
||||
{
|
||||
@@ -1467,7 +1467,7 @@ out_error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const BYTE* http_response_get_body(const HttpResponse* response)
|
||||
const char* http_response_get_body(const HttpResponse* response)
|
||||
{
|
||||
if (!response)
|
||||
return NULL;
|
||||
|
||||
@@ -128,7 +128,7 @@ FREERDP_LOCAL HttpResponse* http_response_recv(rdpTls* tls, BOOL readContentLeng
|
||||
|
||||
FREERDP_LOCAL UINT16 http_response_get_status_code(const HttpResponse* response);
|
||||
FREERDP_LOCAL size_t http_response_get_body_length(const HttpResponse* response);
|
||||
FREERDP_LOCAL const BYTE* http_response_get_body(const HttpResponse* response);
|
||||
FREERDP_LOCAL const char* http_response_get_body(const HttpResponse* response);
|
||||
FREERDP_LOCAL const char* http_response_get_auth_token(const HttpResponse* response,
|
||||
const char* method);
|
||||
FREERDP_LOCAL const char* http_response_get_setcookie(const HttpResponse* response,
|
||||
|
||||
@@ -401,6 +401,7 @@ extern "C"
|
||||
* @return A string representation of the JSON instance or \b NULL
|
||||
* @since version 3.6.0
|
||||
*/
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
WINPR_API char* WINPR_JSON_Print(WINPR_JSON* item);
|
||||
|
||||
/**
|
||||
@@ -411,6 +412,7 @@ extern "C"
|
||||
* @return A string representation of the JSON instance or \b NULL
|
||||
* @since version 3.6.0
|
||||
*/
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
WINPR_API char* WINPR_JSON_PrintUnformatted(WINPR_JSON* item);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user