[warnings] fix integer narrowing
fix function freerdp_tls_write_all
This commit is contained in:
parent
503b9f0bb7
commit
f00d9c45e0
@ -239,9 +239,7 @@ static BOOL arm_send_http_request(rdpArm* arm, rdpTls* tls, const char* method,
|
||||
return FALSE;
|
||||
|
||||
const size_t sz = Stream_Length(s);
|
||||
|
||||
if (sz <= INT_MAX)
|
||||
status = freerdp_tls_write_all(tls, Stream_Buffer(s), sz);
|
||||
status = freerdp_tls_write_all(tls, Stream_Buffer(s), sz);
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
if (status >= 0 && content_length > 0 && data)
|
||||
|
@ -1238,18 +1238,14 @@ static BOOL rdg_auth_init(rdpRdg* rdg, rdpTls* tls, TCHAR* authPkg)
|
||||
static BOOL rdg_send_http_request(rdpRdg* rdg, rdpTls* tls, const char* method,
|
||||
TRANSFER_ENCODING transferEncoding)
|
||||
{
|
||||
size_t sz = 0;
|
||||
wStream* s = NULL;
|
||||
int status = -1;
|
||||
s = rdg_build_http_request(rdg, method, transferEncoding);
|
||||
wStream* s = rdg_build_http_request(rdg, method, transferEncoding);
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
sz = Stream_Length(s);
|
||||
|
||||
if (sz <= INT_MAX)
|
||||
status = freerdp_tls_write_all(tls, Stream_Buffer(s), sz);
|
||||
const size_t sz = Stream_Length(s);
|
||||
status = freerdp_tls_write_all(tls, Stream_Buffer(s), sz);
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
return (status >= 0);
|
||||
|
@ -332,21 +332,15 @@ out:
|
||||
|
||||
static BOOL wst_send_http_request(rdpWst* wst, rdpTls* tls)
|
||||
{
|
||||
size_t sz = 0;
|
||||
wStream* s = NULL;
|
||||
int status = -1;
|
||||
WINPR_ASSERT(wst);
|
||||
WINPR_ASSERT(tls);
|
||||
|
||||
s = wst_build_http_request(wst);
|
||||
|
||||
wStream* s = wst_build_http_request(wst);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
sz = Stream_Length(s);
|
||||
|
||||
if (sz <= INT_MAX)
|
||||
status = freerdp_tls_write_all(tls, Stream_Buffer(s), sz);
|
||||
const size_t sz = Stream_Length(s);
|
||||
int status = freerdp_tls_write_all(tls, Stream_Buffer(s), sz);
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
return (status >= 0);
|
||||
|
@ -1236,22 +1236,22 @@ BOOL freerdp_tls_send_alert(rdpTls* tls)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int freerdp_tls_write_all(rdpTls* tls, const BYTE* data, int length)
|
||||
int freerdp_tls_write_all(rdpTls* tls, const BYTE* data, size_t length)
|
||||
{
|
||||
WINPR_ASSERT(tls);
|
||||
int offset = 0;
|
||||
size_t offset = 0;
|
||||
BIO* bio = tls->bio;
|
||||
|
||||
if (length > INT32_MAX)
|
||||
return -1;
|
||||
|
||||
while (offset < length)
|
||||
{
|
||||
ERR_clear_error();
|
||||
const int rc = BIO_write(bio, &data[offset], length - offset);
|
||||
const int status = BIO_write(bio, &data[offset], (int)(length - offset));
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (rc > 0)
|
||||
offset += rc;
|
||||
if (status > 0)
|
||||
offset += (size_t)status;
|
||||
else
|
||||
{
|
||||
if (!BIO_should_retry(bio))
|
||||
@ -1259,8 +1259,8 @@ int freerdp_tls_write_all(rdpTls* tls, const BYTE* data, int length)
|
||||
|
||||
if (BIO_write_blocked(bio))
|
||||
{
|
||||
const long status = BIO_wait_write(bio, 100);
|
||||
if (status < 0)
|
||||
const long rc = BIO_wait_write(bio, 100);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
}
|
||||
else if (BIO_read_blocked(bio))
|
||||
@ -1270,7 +1270,7 @@ int freerdp_tls_write_all(rdpTls* tls, const BYTE* data, int length)
|
||||
}
|
||||
}
|
||||
|
||||
return length;
|
||||
return (int)length;
|
||||
}
|
||||
|
||||
int freerdp_tls_set_alert_code(rdpTls* tls, int level, int description)
|
||||
|
@ -115,7 +115,7 @@ extern "C"
|
||||
|
||||
FREERDP_LOCAL BOOL freerdp_tls_send_alert(rdpTls* tls);
|
||||
|
||||
FREERDP_LOCAL int freerdp_tls_write_all(rdpTls* tls, const BYTE* data, int length);
|
||||
FREERDP_LOCAL int freerdp_tls_write_all(rdpTls* tls, const BYTE* data, size_t length);
|
||||
|
||||
FREERDP_LOCAL int freerdp_tls_set_alert_code(rdpTls* tls, int level, int description);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user