/* First check if there are buffered bytes already decoded */
if (ctx->buf_len > 0) {
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
i = ctx->buf_len - ctx->buf_off;
if (i > outl)
i = outl;
- OPENSSL_assert(ctx->buf_off + i < (int)sizeof(ctx->buf));
+ if (!ossl_assert(ctx->buf_off + i < (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
memcpy(out, &(ctx->buf[ctx->buf_off]), i);
ret = i;
out += i;
ctx->tmp_len = 0;
EVP_EncodeInit(ctx->base64);
}
-
- OPENSSL_assert(ctx->buf_off < (int)sizeof(ctx->buf));
- OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_off < (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
+ if (!ossl_assert(ctx->buf_len <= (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
n = ctx->buf_len - ctx->buf_off;
while (n > 0) {
i = BIO_write(next, &(ctx->buf[ctx->buf_off]), n);
BIO_copy_next_retry(b);
return i;
}
- OPENSSL_assert(i <= n);
ctx->buf_off += i;
- OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf));
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_off <= (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
n -= i;
}
/* at this point all pending data has been written */
if ((BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) != 0) {
if (ctx->tmp_len > 0) {
- OPENSSL_assert(ctx->tmp_len <= 3);
+ if (!ossl_assert(ctx->tmp_len <= 3)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
n = 3 - ctx->tmp_len;
/*
* There's a theoretical possibility for this
break;
ctx->buf_len =
EVP_EncodeBlock(ctx->buf, ctx->tmp, ctx->tmp_len);
- OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_len <= (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
/*
* Since we're now done using the temporary buffer, the
* length should be 0'd
n -= n % 3;
ctx->buf_len =
EVP_EncodeBlock(ctx->buf, (unsigned char *)in, n);
- OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_len <= (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
ret += n;
}
} else {
if (!EVP_EncodeUpdate(ctx->base64, ctx->buf, &ctx->buf_len,
(unsigned char *)in, n))
return ret == 0 ? -1 : ret;
- OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_len <= (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
ret += n;
}
inl -= n;
BIO_copy_next_retry(b);
return ret == 0 ? i : ret;
}
- OPENSSL_assert(i <= n);
n -= i;
ctx->buf_off += i;
- OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf));
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_off <= (int)sizeof(ctx->buf))) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return ret == 0 ? -1 : ret;
+ }
}
ctx->buf_len = 0;
ctx->buf_off = 0;
ret = BIO_ctrl(next, cmd, num, ptr);
break;
case BIO_CTRL_WPENDING: /* More to write in buffer */
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
ret = ctx->buf_len - ctx->buf_off;
if (ret == 0 && ctx->encode != B64_NONE
&& EVP_ENCODE_CTX_num(ctx->base64) != 0)
ret = BIO_ctrl(next, cmd, num, ptr);
break;
case BIO_CTRL_PENDING: /* More to read in buffer */
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ if (!ossl_assert(ctx->buf_len >= ctx->buf_off)) {
+ ERR_raise(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR);
+ return -1;
+ }
ret = ctx->buf_len - ctx->buf_off;
if (ret <= 0)
ret = BIO_ctrl(next, cmd, num, ptr);