diff --git a/libfreerdp/core/childsession.c b/libfreerdp/core/childsession.c index 51973d5d8..bcc58e364 100644 --- a/libfreerdp/core/childsession.c +++ b/libfreerdp/core/childsession.c @@ -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) diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index 85640f820..dbfdf77bf 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -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) diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 456ba84b6..f76081daa 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -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, diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 4ccdb37dd..b3ab34e82 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -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,