/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
long ret;
int bareoper;
- if (b->callback_ex != NULL) {
+ if (b->callback_ex != NULL)
return b->callback_ex(b, oper, argp, len, argi, argl, inret, processed);
- }
/* Strip off any BIO_CB_RETURN flag */
bareoper = oper & ~BIO_CB_RETURN;
return -1;
argi = (int)len;
+ }
- if (inret && (oper & BIO_CB_RETURN)) {
- if (*processed > INT_MAX)
- return -1;
- inret = *processed;
- }
+ if (inret && (oper & BIO_CB_RETURN) && bareoper != BIO_CB_CTRL) {
+ if (*processed > INT_MAX)
+ return -1;
+ inret = *processed;
}
ret = b->callback(b, oper, argp, argi, argl, inret);
- if (ret >= 0 && (HAS_LEN_OPER(bareoper) || bareoper == BIO_CB_PUTS)) {
+ if (ret >= 0 && (oper & BIO_CB_RETURN) && bareoper != BIO_CB_CTRL) {
*processed = (size_t)ret;
ret = 1;
}
CRYPTO_THREAD_lock_free(bio->lock);
goto err;
}
+ if (method->create == NULL)
+ bio->init = 1;
return bio;
if ((b->callback != NULL || b->callback_ex != NULL) &&
((ret = (int)bio_call_callback(b, BIO_CB_READ, data, dlen, 0, 0L, 1L,
- readbytes)) <= 0))
+ NULL)) <= 0))
return ret;
if (!b->init) {
if ((b->callback != NULL || b->callback_ex != NULL) &&
((ret = (int)bio_call_callback(b, BIO_CB_WRITE, data, dlen, 0, 0L, 1L,
- written)) <= 0))
+ NULL)) <= 0))
return ret;
if (!b->init) {
if (b == NULL)
return 0;
- if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) {
+ if ((b->method == NULL) || (b->method->callback_ctrl == NULL)
+ || (cmd != BIO_CTRL_SET_CALLBACK)) {
BIOerr(BIO_F_BIO_CALLBACK_CTRL, BIO_R_UNSUPPORTED_METHOD);
return -2;
}