The return type is ssize_t, not int, but some callers didn't handle
this properly.
The BIO callbacks are constrained by the OpenSSL API, so they take int
for the length and return int. This is safe, since the return value
can't be greater than the input length. To make it more clear that
this is intentional, cast the result of the
secure_read()/secure_write() call to int explicitly.
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://www.postgresql.org/message-id/flat/
f9aab072-0078-49e4-ab93-
3b08086a4406@eisentraut.org
if (buf != NULL)
{
- res = secure_raw_read(port, buf, size);
+ res = (int) secure_raw_read(port, buf, size);
BIO_clear_retry_flags(h);
port->last_read_was_eof = res == 0;
if (res <= 0)
{
int res = 0;
- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
+ res = (int) secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
/* Can fill buffer from PqRecvLength and upwards */
for (;;)
{
- int r;
+ ssize_t r;
errno = 0;
int
pq_getbyte_if_available(unsigned char *c)
{
- int r;
+ ssize_t r;
Assert(PqCommReadingMsg);
while (bufptr < bufend)
{
- int r;
+ ssize_t r;
r = secure_write(MyProcPort, bufptr, bufend - bufptr);
pqReadData_internal(PGconn *conn)
{
int someread = 0;
- int nread;
+ ssize_t nread;
/* Left-justify any data in the buffer to make room */
if (conn->inStart < conn->inEnd)
/* while there's still data to send */
while (len > 0)
{
- int sent;
+ ssize_t sent;
#ifndef WIN32
sent = pqsecure_write(conn, ptr, len);
PGconn *conn = (PGconn *) BIO_get_data(h);
int res;
- res = pqsecure_raw_read(conn, buf, size);
+ res = (int) pqsecure_raw_read(conn, buf, size);
BIO_clear_retry_flags(h);
conn->last_read_was_eof = res == 0;
if (res < 0)
{
int res;
- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
+ res = (int) pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{