Fix unnecessary casts between int and size_t

Also update a check for a negative int length value
in mem_write().

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26438)
This commit is contained in:
Frederik Wedel-Heinen 2025-01-16 10:27:31 +01:00 committed by Tomas Mraz
parent 3e7afad062
commit cb7da43fe8
3 changed files with 3 additions and 3 deletions

View File

@ -222,7 +222,7 @@ static int mem_write(BIO *b, const char *in, int inl)
goto end;
}
BIO_clear_retry_flags(b);
if (inl == 0)
if (inl <= 0)
return 0;
if (in == NULL) {
ERR_raise(ERR_LIB_BIO, ERR_R_PASSED_NULL_PARAMETER);

View File

@ -672,7 +672,7 @@ int do_dtls1_write(SSL_CONNECTION *sc, uint8_t type, const unsigned char *buf,
sc->rlayer.wrlmethod->write_records(sc->rlayer.wrl, &tmpl, 1));
if (ret > 0)
*written = (int)len;
*written = len;
return ret;
}

View File

@ -547,7 +547,7 @@ static int grow_init_buf(SSL_CONNECTION *s, size_t size) {
size_t msg_offset = (char *)s->init_msg - s->init_buf->data;
if (!BUF_MEM_grow_clean(s->init_buf, (int)size))
if (!BUF_MEM_grow_clean(s->init_buf, size))
return 0;
if (size < msg_offset)