[core] fix BIO_puts implementations

* return -2 if not implemented
* add length sanitizion checks
This commit is contained in:
akallabeth
2025-09-01 09:02:34 +02:00
parent aa6062e014
commit ed90a55adf
4 changed files with 8 additions and 4 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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,

View File

@@ -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,