{ERR_FUNC(BIO_F_BIO_PUTS), "BIO_puts"},
{ERR_FUNC(BIO_F_BIO_READ), "BIO_read"},
{ERR_FUNC(BIO_F_BIO_READ_EX), "BIO_read_ex"},
+ {ERR_FUNC(BIO_F_BIO_READ_INTERN), "bio_read_intern"},
{ERR_FUNC(BIO_F_BIO_SOCKET), "BIO_socket"},
{ERR_FUNC(BIO_F_BIO_SOCKET_NBIO), "BIO_socket_nbio"},
{ERR_FUNC(BIO_F_BIO_SOCK_INFO), "BIO_sock_info"},
{ERR_FUNC(BIO_F_BIO_SOCK_INIT), "BIO_sock_init"},
{ERR_FUNC(BIO_F_BIO_WRITE), "BIO_write"},
{ERR_FUNC(BIO_F_BIO_WRITE_EX), "BIO_write_ex"},
+ {ERR_FUNC(BIO_F_BIO_WRITE_INTERN), "bio_write_intern"},
{ERR_FUNC(BIO_F_BUFFER_CTRL), "buffer_ctrl"},
{ERR_FUNC(BIO_F_CONN_CTRL), "conn_ctrl"},
{ERR_FUNC(BIO_F_CONN_STATE), "conn_state"},
{ERR_REASON(BIO_R_INVALID_ARGUMENT), "invalid argument"},
{ERR_REASON(BIO_R_INVALID_SOCKET), "invalid socket"},
{ERR_REASON(BIO_R_IN_USE), "in use"},
+ {ERR_REASON(BIO_R_LENGTH_TOO_LONG), "length too long"},
{ERR_REASON(BIO_R_LISTEN_V6_ONLY), "listen v6 only"},
{ERR_REASON(BIO_R_LOOKUP_RETURNED_NOTHING), "lookup returned nothing"},
{ERR_REASON(BIO_R_MALFORMED_HOST_OR_SERVICE),
ret = b->callback(b, oper, argp, argi, argl, inret);
- if (ret > LONG_MAX || ret < LONG_MIN)
- return -1;
-
if (ret >= 0 && (HAS_LEN_OPER(bareoper) || bareoper == BIO_CB_PUTS)) {
*processed = (size_t)ret;
ret = 1;
/*
* This is essentially the same as BIO_read_ex() except that it allows
- * 0 or a -ve value to indicate failure (retryable or not) in the return. This
- * is for compatibility with the old style BIO_read(), where existing code may
- * make assumptions about the return value that it might get.
+ * 0 or a negative value to indicate failure (retryable or not) in the return.
+ * This is for compatibility with the old style BIO_read(), where existing code
+ * may make assumptions about the return value that it might get.
*/
-static int bio_read_intern(BIO *b, void *data, size_t datal, size_t *read)
+static int bio_read_intern(BIO *b, void *data, size_t dlen, size_t *read)
{
int ret;
if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {
- BIOerr(BIO_F_BIO_READ_EX, BIO_R_UNSUPPORTED_METHOD);
+ BIOerr(BIO_F_BIO_READ_INTERN, BIO_R_UNSUPPORTED_METHOD);
return -2;
}
if ((b->callback != NULL || b->callback_ex != NULL) &&
- ((ret = (int)bio_call_callback(b, BIO_CB_READ, data, datal, 0, 0L, 1L,
+ ((ret = (int)bio_call_callback(b, BIO_CB_READ, data, dlen, 0, 0L, 1L,
read)) <= 0))
return ret;
if (!b->init) {
- BIOerr(BIO_F_BIO_READ_EX, BIO_R_UNINITIALIZED);
+ BIOerr(BIO_F_BIO_READ_INTERN, BIO_R_UNINITIALIZED);
return -2;
}
- ret = b->method->bread(b, data, datal, read);
+ ret = b->method->bread(b, data, dlen, read);
if (ret > 0)
b->num_read += (uint64_t)*read;
if (b->callback != NULL || b->callback_ex != NULL)
ret = (int)bio_call_callback(b, BIO_CB_READ | BIO_CB_RETURN, data,
- datal, 0, 0L, ret, read);
+ dlen, 0, 0L, ret, read);
/* Shouldn't happen */
- if (ret > 0 && *read > datal)
+ if (ret > 0 && *read > dlen) {
+ BIOerr(BIO_F_BIO_READ_INTERN, ERR_R_INTERNAL_ERROR);
return -1;
+ }
return ret;
}
-int BIO_read(BIO *b, void *data, int datal)
+int BIO_read(BIO *b, void *data, int dlen)
{
size_t read;
int ret;
- if (datal < 0)
+ if (dlen < 0)
return 0;
- ret = bio_read_intern(b, data, (size_t)datal, &read);
+ ret = bio_read_intern(b, data, (size_t)dlen, &read);
if (ret > 0) {
/* *read should always be <= outl */
return ret;
}
-int BIO_read_ex(BIO *b, void *data, size_t datal, size_t *read)
+int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *read)
{
int ret;
- ret = bio_read_intern(b, data, datal, read);
+ ret = bio_read_intern(b, data, dlen, read);
if (ret > 0)
ret = 1;
return ret;
}
-static int bio_write_intern(BIO *b, const void *data, size_t datal,
+static int bio_write_intern(BIO *b, const void *data, size_t dlen,
size_t *written)
{
int ret;
return 0;
if ((b->method == NULL) || (b->method->bwrite == NULL)) {
- BIOerr(BIO_F_BIO_WRITE_EX, BIO_R_UNSUPPORTED_METHOD);
+ BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNSUPPORTED_METHOD);
return -2;
}
if ((b->callback != NULL || b->callback_ex != NULL) &&
- ((ret = (int)bio_call_callback(b, BIO_CB_WRITE, data, datal, 0, 0L, 1L,
+ ((ret = (int)bio_call_callback(b, BIO_CB_WRITE, data, dlen, 0, 0L, 1L,
written)) <= 0))
return ret;
if (!b->init) {
- BIOerr(BIO_F_BIO_WRITE_EX, BIO_R_UNINITIALIZED);
+ BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNINITIALIZED);
return -2;
}
- ret = b->method->bwrite(b, data, datal, written);
+ ret = b->method->bwrite(b, data, dlen, written);
if (ret > 0)
b->num_write += (uint64_t)*written;
if (b->callback != NULL || b->callback_ex != NULL)
ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, data,
- datal, 0, 0L, ret, written);
+ dlen, 0, 0L, ret, written);
return ret;
}
-int BIO_write(BIO *b, const void *data, int datal)
+int BIO_write(BIO *b, const void *data, int dlen)
{
size_t written;
int ret;
- if (datal < 0)
+ if (dlen < 0)
return 0;
- ret = bio_write_intern(b, data, (size_t)datal, &written);
+ ret = bio_write_intern(b, data, (size_t)dlen, &written);
if (ret > 0) {
/* *written should always be <= inl */
return ret;
}
-int BIO_write_ex(BIO *b, const void *data, size_t datal, size_t *written)
+int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written)
{
int ret;
- ret = bio_write_intern(b, data, datal, written);
+ ret = bio_write_intern(b, data, dlen, written);
if (ret > 0)
ret = 1;
0L, ret, &written);
if (ret > 0) {
- if (written > INT_MAX)
+ if (written > INT_MAX) {
+ BIOerr(BIO_F_BIO_PUTS, BIO_R_LENGTH_TOO_LONG);
ret = -1;
- else
+ } else {
ret = (int)written;
+ }
}
return ret;
int BIO_get_shutdown(BIO *a);
void BIO_vfree(BIO *a);
int BIO_up_ref(BIO *a);
-int BIO_read(BIO *b, void *data, int datal);
-int BIO_read_ex(BIO *b, void *data, size_t datal, size_t *read);
+int BIO_read(BIO *b, void *data, int dlen);
+int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *read);
int BIO_gets(BIO *bp, char *buf, int size);
-int BIO_write(BIO *b, const void *data, int datal);
-int BIO_write_ex(BIO *b, const void *data, size_t datal, size_t *written);
+int BIO_write(BIO *b, const void *data, int dlen);
+int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
int BIO_puts(BIO *bp, const char *buf);
int BIO_indent(BIO *b, int indent, int max);
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
# define BIO_F_BIO_PUTS 110
# define BIO_F_BIO_READ 111
# define BIO_F_BIO_READ_EX 105
+# define BIO_F_BIO_READ_INTERN 120
# define BIO_F_BIO_SOCKET 140
# define BIO_F_BIO_SOCKET_NBIO 142
# define BIO_F_BIO_SOCK_INFO 141
# define BIO_F_BIO_SOCK_INIT 112
# define BIO_F_BIO_WRITE 113
# define BIO_F_BIO_WRITE_EX 119
+# define BIO_F_BIO_WRITE_INTERN 128
# define BIO_F_BUFFER_CTRL 114
# define BIO_F_CONN_CTRL 127
# define BIO_F_CONN_STATE 115
# define BIO_R_INVALID_ARGUMENT 125
# define BIO_R_INVALID_SOCKET 135
# define BIO_R_IN_USE 123
+# define BIO_R_LENGTH_TOO_LONG 102
# define BIO_R_LISTEN_V6_ONLY 136
# define BIO_R_LOOKUP_RETURNED_NOTHING 142
# define BIO_R_MALFORMED_HOST_OR_SERVICE 130