diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c index 31d9dc0a..27b2763a 100644 --- a/ssl/d1_pkt.c +++ b/ssl/d1_pkt.c @@ -331,7 +331,7 @@ void dtls1_read_close_notify(SSL *ssl) { } } -int dtls1_write_app_data(SSL *ssl, const void *buf_, int len) { +int dtls1_write_app_data(SSL *ssl, const uint8_t *buf, int len) { assert(!SSL_in_init(ssl)); if (len > SSL3_RT_MAX_PLAIN_LENGTH) { @@ -348,7 +348,7 @@ int dtls1_write_app_data(SSL *ssl, const void *buf_, int len) { return 0; } - int ret = dtls1_write_record(ssl, SSL3_RT_APPLICATION_DATA, buf_, (size_t)len, + int ret = dtls1_write_record(ssl, SSL3_RT_APPLICATION_DATA, buf, (size_t)len, dtls1_use_current_epoch); if (ret <= 0) { return ret; diff --git a/ssl/internal.h b/ssl/internal.h index cba14cdd..544259c0 100644 --- a/ssl/internal.h +++ b/ssl/internal.h @@ -1319,11 +1319,11 @@ struct ssl_protocol_method_st { * and sets |*out_got_handshake| to whether the failure was due to a * post-handshake handshake message. If so, it fills in the current message as * in |ssl_get_message|. */ - int (*read_app_data)(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len, + int (*read_app_data)(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len, int peek); int (*read_change_cipher_spec)(SSL *ssl); void (*read_close_notify)(SSL *ssl); - int (*write_app_data)(SSL *ssl, const void *buf_, int len); + int (*write_app_data)(SSL *ssl, const uint8_t *buf, int len); int (*dispatch_alert)(SSL *ssl); /* supports_cipher returns one if |cipher| is supported by this protocol and * zero otherwise. */ @@ -1796,8 +1796,7 @@ int ssl3_read_app_data(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len, int ssl3_read_change_cipher_spec(SSL *ssl); void ssl3_read_close_notify(SSL *ssl); int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len); -int ssl3_write_app_data(SSL *ssl, const void *buf, int len); -int ssl3_write_bytes(SSL *ssl, int type, const void *buf, int len); +int ssl3_write_app_data(SSL *ssl, const uint8_t *buf, int len); int ssl3_output_cert_chain(SSL *ssl); int ssl3_new(SSL *ssl); @@ -1838,7 +1837,7 @@ int dtls1_read_app_data(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len, int dtls1_read_change_cipher_spec(SSL *ssl); void dtls1_read_close_notify(SSL *ssl); -int dtls1_write_app_data(SSL *ssl, const void *buf, int len); +int dtls1_write_app_data(SSL *ssl, const uint8_t *buf, int len); /* dtls1_write_record sends a record. It returns one on success and <= 0 on * error. */ diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c index 84f52b56..5d5b7e83 100644 --- a/ssl/s3_pkt.c +++ b/ssl/s3_pkt.c @@ -188,16 +188,9 @@ again: return -1; } -int ssl3_write_app_data(SSL *ssl, const void *buf, int len) { +int ssl3_write_app_data(SSL *ssl, const uint8_t *buf, int len) { assert(!SSL_in_init(ssl) || SSL_in_false_start(ssl)); - return ssl3_write_bytes(ssl, SSL3_RT_APPLICATION_DATA, buf, len); -} - -/* Call this to write data in records of type |type|. It will return <= 0 if - * not all data has been sent or non-blocking IO. */ -int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) { - const uint8_t *buf = buf_; unsigned tot, n, nw; assert(ssl->s3->wnum <= INT_MAX); @@ -216,7 +209,7 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) { return -1; } - n = (len - tot); + n = len - tot; for (;;) { /* max contains the maximum number of bytes that we can put into a * record. */ @@ -227,14 +220,13 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) { nw = n; } - int ret = do_ssl3_write(ssl, type, &buf[tot], nw); + int ret = do_ssl3_write(ssl, SSL3_RT_APPLICATION_DATA, &buf[tot], nw); if (ret <= 0) { ssl->s3->wnum = tot; return ret; } - if (ret == (int)n || (type == SSL3_RT_APPLICATION_DATA && - (ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { + if (ret == (int)n || (ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE)) { return tot + ret; }