mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
[core] fix BIO_puts implementations
* return -2 if not implemented * add length sanitizion checks
This commit is contained in:
@@ -256,7 +256,11 @@ static int transport_bio_named_puts(BIO* bio, const char* str)
|
||||
WINPR_ASSERT(bio);
|
||||
WINPR_ASSERT(str);
|
||||
|
||||
return transport_bio_named_write(bio, str, (int)strnlen(str, INT32_MAX));
|
||||
const int max = (INT_MAX > SIZE_MAX) ? SIZE_MAX : INT_MAX;
|
||||
const size_t len = strnlen(str, max);
|
||||
if (len >= max)
|
||||
return -1;
|
||||
return transport_bio_named_write(bio, str, WINPR_ASSERTING_INT_CAST(int, len));
|
||||
}
|
||||
|
||||
static int transport_bio_named_gets(BIO* bio, char* str, int size)
|
||||
|
||||
@@ -2961,7 +2961,7 @@ static int transport_bio_tsg_puts(BIO* bio, const char* str)
|
||||
{
|
||||
WINPR_UNUSED(bio);
|
||||
WINPR_UNUSED(str);
|
||||
return 1;
|
||||
return -2;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-non-const-parameter)
|
||||
|
||||
@@ -174,7 +174,7 @@ static int transport_bio_simple_read(BIO* bio, char* buf, int size)
|
||||
|
||||
static int transport_bio_simple_puts(WINPR_ATTR_UNUSED BIO* bio, WINPR_ATTR_UNUSED const char* str)
|
||||
{
|
||||
return 1;
|
||||
return -2;
|
||||
}
|
||||
|
||||
static int transport_bio_simple_gets(WINPR_ATTR_UNUSED BIO* bio, WINPR_ATTR_UNUSED char* str,
|
||||
|
||||
@@ -2012,7 +2012,7 @@ static int transport_layer_bio_read(BIO* bio, char* buf, int size)
|
||||
|
||||
static int transport_layer_bio_puts(WINPR_ATTR_UNUSED BIO* bio, WINPR_ATTR_UNUSED const char* str)
|
||||
{
|
||||
return 1;
|
||||
return -2;
|
||||
}
|
||||
|
||||
static int transport_layer_bio_gets(WINPR_ATTR_UNUSED BIO* bio, WINPR_ATTR_UNUSED char* str,
|
||||
|
||||
Reference in New Issue
Block a user