Skip to content

Commit

Permalink
QUIC: SSLerr() -> ERR_raise(ERR_LIB_SSL)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmshort committed Mar 3, 2021
1 parent bf2ab6e commit ff580e3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ssl/s3_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int ssl3_dispatch_alert(SSL *s)
if (SSL_IS_QUIC(s)) {
if (!s->quic_method->send_alert(s, s->quic_write_level,
s->s3.send_alert[1])) {
SSLerr(SSL_F_SSL3_DISPATCH_ALERT, ERR_R_INTERNAL_ERROR);
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
}
i = 1;
Expand Down
6 changes: 3 additions & 3 deletions ssl/ssl_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ int ssl_read_internal(SSL *s, void *buf, size_t num, size_t *readbytes)
{
#ifndef OPENSSL_NO_QUIC
if (SSL_IS_QUIC(s)) {
SSLerr(SSL_F_SSL_READ_INTERNAL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return -1;
}
#endif
Expand Down Expand Up @@ -1965,7 +1965,7 @@ static int ssl_peek_internal(SSL *s, void *buf, size_t num, size_t *readbytes)
{
#ifndef OPENSSL_NO_QUIC
if (SSL_IS_QUIC(s)) {
SSLerr(SSL_F_SSL_PEEK_INTERNAL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return -1;
}
#endif
Expand Down Expand Up @@ -2031,7 +2031,7 @@ int ssl_write_internal(SSL *s, const void *buf, size_t num, size_t *written)
{
#ifndef OPENSSL_NO_QUIC
if (SSL_IS_QUIC(s)) {
SSLerr(SSL_F_SSL_WRITE_INTERNAL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return -1;
}
#endif
Expand Down
17 changes: 8 additions & 9 deletions ssl/ssl_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,26 @@ int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level,
size_t l, offset;

if (!SSL_IS_QUIC(ssl)) {
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
}

/* Level can be different than the current read, but not less */
if (level < ssl->quic_read_level
|| (ssl->quic_input_data_tail != NULL && level < ssl->quic_input_data_tail->level)
|| level < ssl->quic_latest_level_received) {
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
ERR_raise(ERR_LIB_SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
return 0;
}

if (ssl->quic_buf == NULL) {
BUF_MEM *buf;
if ((buf = BUF_MEM_new()) == NULL) {
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
}
if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
BUF_MEM_free(buf);
return 0;
}
Expand All @@ -163,15 +163,14 @@ int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level,
/* A TLS message must not cross an encryption level boundary */
if (ssl->quic_buf->length != ssl->quic_next_record_start
&& level != ssl->quic_latest_level_received) {
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA,
SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
ERR_raise(ERR_LIB_SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
return 0;
}
ssl->quic_latest_level_received = level;

offset = ssl->quic_buf->length;
if (!BUF_MEM_grow(ssl->quic_buf, offset + len)) {
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
}
memcpy(ssl->quic_buf->data + offset, data, len);
Expand All @@ -193,7 +192,7 @@ int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level,

qd = OPENSSL_zalloc(sizeof(*qd));
if (qd == NULL) {
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
}

Expand Down Expand Up @@ -305,7 +304,7 @@ int SSL_process_quic_post_handshake(SSL *ssl)
int ret;

if (SSL_in_init(ssl) || !SSL_IS_QUIC(ssl)) {
SSLerr(SSL_F_SSL_PROCESS_QUIC_POST_HANDSHAKE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion ssl/statem/statem.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ int statem_flush(SSL *s)
#ifndef OPENSSL_NO_QUIC
if (SSL_IS_QUIC(s)) {
if (!s->quic_method->flush_flight(s)) {
SSLerr(SSL_F_STATEM_FLUSH, ERR_R_INTERNAL_ERROR);
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
}
} else
Expand Down
4 changes: 2 additions & 2 deletions ssl/statem/statem_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ int ssl3_do_write(SSL *s, int type)
if (!ret) {
ret = -1;
/* QUIC can't sent anything out sice the above failed */
SSLerr(SSL_F_SSL3_DO_WRITE, ERR_R_INTERNAL_ERROR);
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
} else {
written = s->init_num;
}
} else {
/* QUIC doesn't use ChangeCipherSpec */
ret = -1;
SSLerr(SSL_F_SSL3_DO_WRITE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
}
} else
#endif
Expand Down

0 comments on commit ff580e3

Please sign in to comment.