Blame SOURCES/gnutls-3.6.8-decr-len.patch

cde47b
From e0fe31f1fc2ba13ada1d6bc35231847b75be4ee9 Mon Sep 17 00:00:00 2001
cde47b
From: Daiki Ueno <dueno@redhat.com>
cde47b
Date: Thu, 8 Aug 2019 18:02:08 +0200
cde47b
Subject: [PATCH 1/2] gnutls_int.h: make DECR_LEN neutral to signedness
cde47b
cde47b
DECR_LEN was previously implemented in a way that it first decrements
cde47b
the given length and then checks whether the result is negative.  This
cde47b
requires the caller to properly coerce the length argument to a signed
cde47b
integer, before invoking the macro.
cde47b
cde47b
Signed-off-by: Daiki Ueno <dueno@redhat.com>
cde47b
---
cde47b
 lib/gnutls_int.h | 11 ++++++-----
cde47b
 1 file changed, 6 insertions(+), 5 deletions(-)
cde47b
cde47b
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
cde47b
index 179d71b4a..7f7b6a7c9 100644
cde47b
--- a/lib/gnutls_int.h
cde47b
+++ b/lib/gnutls_int.h
cde47b
@@ -256,14 +256,15 @@ typedef enum record_send_state_t {
cde47b
 
cde47b
 #define MEMSUB(x,y) ((ssize_t)((ptrdiff_t)x-(ptrdiff_t)y))
cde47b
 
cde47b
-#define DECR_LEN(len, x) do { len-=x; if (len<0) {gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;} } while (0)
cde47b
+#define DECR_LEN(len, x) DECR_LENGTH_RET(len, x, GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
cde47b
 #define DECR_LEN_FINAL(len, x) do { \
cde47b
-	len-=x; \
cde47b
-	if (len != 0) \
cde47b
+	if (len != x) \
cde47b
 		return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH); \
cde47b
+	else \
cde47b
+		len = 0; \
cde47b
 	} while (0)
cde47b
-#define DECR_LENGTH_RET(len, x, RET) do { len-=x; if (len<0) {gnutls_assert(); return RET;} } while (0)
cde47b
-#define DECR_LENGTH_COM(len, x, COM) do { len-=x; if (len<0) {gnutls_assert(); COM;} } while (0)
cde47b
+#define DECR_LENGTH_RET(len, x, RET) DECR_LENGTH_COM(len, x, return RET)
cde47b
+#define DECR_LENGTH_COM(len, x, COM) do { if (len
cde47b
 
cde47b
 #define GNUTLS_POINTER_TO_INT(_) ((int) GNUTLS_POINTER_TO_INT_CAST (_))
cde47b
 #define GNUTLS_INT_TO_POINTER(_) ((void*) GNUTLS_POINTER_TO_INT_CAST (_))
cde47b
-- 
cde47b
2.21.0
cde47b
cde47b
cde47b
From 5e9b2ec29449c76b1b938a0ebf0dc9b92cae7057 Mon Sep 17 00:00:00 2001
cde47b
From: Daiki Ueno <dueno@redhat.com>
cde47b
Date: Thu, 8 Aug 2019 18:04:18 +0200
cde47b
Subject: [PATCH 2/2] lib/*: remove unnecessary cast to ssize_t
cde47b
cde47b
Signed-off-by: Daiki Ueno <dueno@redhat.com>
cde47b
---
cde47b
 lib/crypto-api.c             | 10 +++++-----
cde47b
 lib/ext/alpn.c               |  3 +--
cde47b
 lib/ext/client_cert_type.c   |  9 ++++-----
cde47b
 lib/ext/cookie.c             |  5 ++---
cde47b
 lib/ext/ec_point_formats.c   |  7 +++----
cde47b
 lib/ext/key_share.c          |  5 ++---
cde47b
 lib/ext/max_record.c         |  3 +--
cde47b
 lib/ext/psk_ke_modes.c       |  3 +--
cde47b
 lib/ext/record_size_limit.c  |  3 +--
cde47b
 lib/ext/safe_renegotiation.c |  3 +--
cde47b
 lib/ext/server_cert_type.c   |  9 ++++-----
cde47b
 lib/ext/server_name.c        |  3 +--
cde47b
 lib/ext/session_ticket.c     |  5 ++---
cde47b
 lib/ext/signature.c          |  3 +--
cde47b
 lib/ext/srp.c                |  3 +--
cde47b
 lib/ext/srtp.c               |  5 ++---
cde47b
 lib/ext/status_request.c     |  3 +--
cde47b
 lib/ext/supported_groups.c   |  3 +--
cde47b
 lib/ext/supported_versions.c |  5 ++---
cde47b
 lib/extv.c                   |  8 ++++----
cde47b
 lib/sslv2_compat.c           |  3 +--
cde47b
 lib/supplemental.c           |  4 ++--
cde47b
 lib/tls13/certificate.c      | 21 +++++++++++----------
cde47b
 lib/tls13/psk_ext_parser.c   |  4 +---
cde47b
 lib/tls13/psk_ext_parser.h   |  4 ++--
cde47b
 lib/tls13/session_ticket.c   |  2 +-
cde47b
 26 files changed, 58 insertions(+), 78 deletions(-)
cde47b
cde47b
diff --git a/lib/crypto-api.c b/lib/crypto-api.c
cde47b
index 2834c0199..09b3d7bfc 100644
cde47b
--- a/lib/crypto-api.c
cde47b
+++ b/lib/crypto-api.c
cde47b
@@ -990,9 +990,9 @@ gnutls_aead_cipher_encryptv(gnutls_aead_cipher_hd_t handle,
cde47b
 	api_aead_cipher_hd_st *h = handle;
cde47b
 	ssize_t ret;
cde47b
 	uint8_t *dst;
cde47b
-	ssize_t dst_size, total = 0;
cde47b
+	size_t dst_size, total = 0;
cde47b
 	uint8_t *p;
cde47b
-	ssize_t blocksize = handle->ctx_enc.e->blocksize;
cde47b
+	size_t blocksize = handle->ctx_enc.e->blocksize;
cde47b
 	struct iov_iter_st iter;
cde47b
 	size_t blocks;
cde47b
 
cde47b
@@ -1071,7 +1071,7 @@ gnutls_aead_cipher_encryptv(gnutls_aead_cipher_hd_t handle,
cde47b
 		if (ret == 0)
cde47b
 			break;
cde47b
 		blocks = ret;
cde47b
-		if (unlikely((size_t) dst_size < blocksize * blocks))
cde47b
+		if (unlikely(dst_size < blocksize * blocks))
cde47b
 			return gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
cde47b
 		ret = _gnutls_cipher_encrypt2(&handle->ctx_enc, p,
cde47b
 					      blocksize * blocks,
cde47b
@@ -1083,7 +1083,7 @@ gnutls_aead_cipher_encryptv(gnutls_aead_cipher_hd_t handle,
cde47b
 		total += blocksize * blocks;
cde47b
 	}
cde47b
 	if (iter.block_offset > 0) {
cde47b
-		if (unlikely((size_t) dst_size < iter.block_offset))
cde47b
+		if (unlikely(dst_size < iter.block_offset))
cde47b
 			return gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
cde47b
 		ret = _gnutls_cipher_encrypt2(&handle->ctx_enc,
cde47b
 					      iter.block, iter.block_offset,
cde47b
@@ -1095,7 +1095,7 @@ gnutls_aead_cipher_encryptv(gnutls_aead_cipher_hd_t handle,
cde47b
 		total += iter.block_offset;
cde47b
 	}
cde47b
 
cde47b
-	if ((size_t)dst_size < tag_size)
cde47b
+	if (dst_size < tag_size)
cde47b
 		return gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
cde47b
 
cde47b
 	_gnutls_cipher_tag(&handle->ctx_enc, dst, tag_size);
cde47b
diff --git a/lib/ext/alpn.c b/lib/ext/alpn.c
cde47b
index 34f6ce09d..b9991f0a1 100644
cde47b
--- a/lib/ext/alpn.c
cde47b
+++ b/lib/ext/alpn.c
cde47b
@@ -51,13 +51,12 @@ const hello_ext_entry_st ext_mod_alpn = {
cde47b
 
cde47b
 static int
cde47b
 _gnutls_alpn_recv_params(gnutls_session_t session,
cde47b
-			 const uint8_t * data, size_t _data_size)
cde47b
+			 const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	unsigned int i;
cde47b
 	int ret;
cde47b
 	const uint8_t *p = data;
cde47b
 	unsigned len1, len;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	alpn_ext_st *priv;
cde47b
 	gnutls_ext_priv_data_t epriv;
cde47b
 	int selected_protocol_index;
cde47b
diff --git a/lib/ext/client_cert_type.c b/lib/ext/client_cert_type.c
cde47b
index 471d42c5f..b627b71f9 100644
cde47b
--- a/lib/ext/client_cert_type.c
cde47b
+++ b/lib/ext/client_cert_type.c
cde47b
@@ -73,7 +73,6 @@ static int _gnutls_client_cert_type_recv_params(gnutls_session_t session,
cde47b
 	gnutls_certificate_type_t cert_type;
cde47b
 
cde47b
 	uint8_t i, found = 0;
cde47b
-	ssize_t len = data_size;
cde47b
 	const uint8_t* pdata = data;
cde47b
 
cde47b
 	/* Only activate this extension if we have cert credentials set
cde47b
@@ -86,7 +85,7 @@ static int _gnutls_client_cert_type_recv_params(gnutls_session_t session,
cde47b
 
cde47b
 		/* Compare packet length with expected packet length. For the
cde47b
 		 * client this is a single byte. */
cde47b
-		if (len != 1) {
cde47b
+		if (data_size != 1) {
cde47b
 			return
cde47b
 					gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cde47b
 		}
cde47b
@@ -136,8 +135,8 @@ static int _gnutls_client_cert_type_recv_params(gnutls_session_t session,
cde47b
 
cde47b
 	} else {	// server mode
cde47b
 		// Compare packet length with expected packet length.
cde47b
-		DECR_LEN(len, 1);
cde47b
-		if (data[0] != len) {
cde47b
+		DECR_LEN(data_size, 1);
cde47b
+		if (data[0] != data_size) {
cde47b
 			return
cde47b
 					gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cde47b
 		}
cde47b
@@ -145,7 +144,7 @@ static int _gnutls_client_cert_type_recv_params(gnutls_session_t session,
cde47b
 
cde47b
 		// Assign the contents of our data buffer to a gnutls_datum_t
cde47b
 		cert_types.data = (uint8_t*)pdata; // Need casting to get rid of 'discards const qualifier' warning
cde47b
-		cert_types.size = len;
cde47b
+		cert_types.size = data_size;
cde47b
 
cde47b
 		// Store the client certificate types in our session
cde47b
 		_gnutls_hello_ext_set_datum(session,
cde47b
diff --git a/lib/ext/cookie.c b/lib/ext/cookie.c
cde47b
index 1e66c3d49..0feb2f0e5 100644
cde47b
--- a/lib/ext/cookie.c
cde47b
+++ b/lib/ext/cookie.c
cde47b
@@ -53,10 +53,9 @@ const hello_ext_entry_st ext_mod_cookie = {
cde47b
 /* Only client sends this extension. */
cde47b
 static int
cde47b
 cookie_recv_params(gnutls_session_t session,
cde47b
-		   const uint8_t * data, size_t _data_size)
cde47b
+		   const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
-	ssize_t data_size = _data_size;
cde47b
-	ssize_t csize;
cde47b
+	size_t csize;
cde47b
 	int ret;
cde47b
 	gnutls_datum_t tmp;
cde47b
 
cde47b
diff --git a/lib/ext/ec_point_formats.c b/lib/ext/ec_point_formats.c
cde47b
index eb59ec139..c702d434c 100644
cde47b
--- a/lib/ext/ec_point_formats.c
cde47b
+++ b/lib/ext/ec_point_formats.c
cde47b
@@ -57,11 +57,10 @@ const hello_ext_entry_st ext_mod_supported_ec_point_formats = {
cde47b
 static int
cde47b
 _gnutls_supported_ec_point_formats_recv_params(gnutls_session_t session,
cde47b
 				     const uint8_t * data,
cde47b
-				     size_t _data_size)
cde47b
+				     size_t data_size)
cde47b
 {
cde47b
-	int len, i;
cde47b
+	size_t len, i;
cde47b
 	int uncompressed = 0;
cde47b
-	int data_size = _data_size;
cde47b
 
cde47b
 	if (session->security_parameters.entity == GNUTLS_CLIENT) {
cde47b
 		if (data_size < 1)
cde47b
@@ -91,7 +90,7 @@ _gnutls_supported_ec_point_formats_recv_params(gnutls_session_t session,
cde47b
 		/* only sanity check here. We only support uncompressed points
cde47b
 		 * and a client must support it thus nothing to check.
cde47b
 		 */
cde47b
-		if (_data_size < 1)
cde47b
+		if (data_size < 1)
cde47b
 			return
cde47b
 			    gnutls_assert_val
cde47b
 			    (GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION);
cde47b
diff --git a/lib/ext/key_share.c b/lib/ext/key_share.c
cde47b
index 599eff8fb..8f0912e69 100644
cde47b
--- a/lib/ext/key_share.c
cde47b
+++ b/lib/ext/key_share.c
cde47b
@@ -504,11 +504,10 @@ client_use_key_share(gnutls_session_t session, const gnutls_group_entry_st *grou
cde47b
 
cde47b
 static int
cde47b
 key_share_recv_params(gnutls_session_t session,
cde47b
-		      const uint8_t * data, size_t _data_size)
cde47b
+		      const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	int ret;
cde47b
-	ssize_t data_size = _data_size;
cde47b
-	ssize_t size;
cde47b
+	size_t size;
cde47b
 	unsigned gid;
cde47b
 	const version_entry_st *ver;
cde47b
 	const gnutls_group_entry_st *group;
cde47b
diff --git a/lib/ext/max_record.c b/lib/ext/max_record.c
cde47b
index dbb98cf62..3cada69be 100644
cde47b
--- a/lib/ext/max_record.c
cde47b
+++ b/lib/ext/max_record.c
cde47b
@@ -65,10 +65,9 @@ const hello_ext_entry_st ext_mod_max_record_size = {
cde47b
 
cde47b
 static int
cde47b
 _gnutls_max_record_recv_params(gnutls_session_t session,
cde47b
-			       const uint8_t * data, size_t _data_size)
cde47b
+			       const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	ssize_t new_size;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 
cde47b
 	if (session->internals.hsk_flags & HSK_RECORD_SIZE_LIMIT_NEGOTIATED)
cde47b
 		return 0;
cde47b
diff --git a/lib/ext/psk_ke_modes.c b/lib/ext/psk_ke_modes.c
cde47b
index da7a55098..8d8effb43 100644
cde47b
--- a/lib/ext/psk_ke_modes.c
cde47b
+++ b/lib/ext/psk_ke_modes.c
cde47b
@@ -106,10 +106,9 @@ psk_ke_modes_send_params(gnutls_session_t session,
cde47b
  */
cde47b
 static int
cde47b
 psk_ke_modes_recv_params(gnutls_session_t session,
cde47b
-			 const unsigned char *data, size_t _len)
cde47b
+			 const unsigned char *data, size_t len)
cde47b
 {
cde47b
 	uint8_t ke_modes_len;
cde47b
-	ssize_t len = _len;
cde47b
 	const version_entry_st *vers = get_version(session);
cde47b
 	gnutls_psk_server_credentials_t cred;
cde47b
 	int dhpsk_pos = MAX_POS;
cde47b
diff --git a/lib/ext/record_size_limit.c b/lib/ext/record_size_limit.c
cde47b
index e9fe6a1d8..0e94fece3 100644
cde47b
--- a/lib/ext/record_size_limit.c
cde47b
+++ b/lib/ext/record_size_limit.c
cde47b
@@ -48,10 +48,9 @@ const hello_ext_entry_st ext_mod_record_size_limit = {
cde47b
 
cde47b
 static int
cde47b
 _gnutls_record_size_limit_recv_params(gnutls_session_t session,
cde47b
-				      const uint8_t * data, size_t _data_size)
cde47b
+				      const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	ssize_t new_size;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	const version_entry_st *vers;
cde47b
 
cde47b
 	DECR_LEN(data_size, 2);
cde47b
diff --git a/lib/ext/safe_renegotiation.c b/lib/ext/safe_renegotiation.c
cde47b
index 6424f45b5..bb4a57e45 100644
cde47b
--- a/lib/ext/safe_renegotiation.c
cde47b
+++ b/lib/ext/safe_renegotiation.c
cde47b
@@ -265,10 +265,9 @@ int _gnutls_ext_sr_send_cs(gnutls_session_t session)
cde47b
 
cde47b
 static int
cde47b
 _gnutls_sr_recv_params(gnutls_session_t session,
cde47b
-		       const uint8_t * data, size_t _data_size)
cde47b
+		       const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	unsigned int len;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	sr_ext_st *priv;
cde47b
 	gnutls_ext_priv_data_t epriv;
cde47b
 	int set = 0, ret;
cde47b
diff --git a/lib/ext/server_cert_type.c b/lib/ext/server_cert_type.c
cde47b
index dbcb3971b..864a44bbc 100644
cde47b
--- a/lib/ext/server_cert_type.c
cde47b
+++ b/lib/ext/server_cert_type.c
cde47b
@@ -73,7 +73,6 @@ static int _gnutls_server_cert_type_recv_params(gnutls_session_t session,
cde47b
 	gnutls_certificate_type_t cert_type;
cde47b
 
cde47b
 	uint8_t i, found = 0;
cde47b
-	ssize_t len = data_size;
cde47b
 	const uint8_t* pdata = data;
cde47b
 
cde47b
 	/* Only activate this extension if we have cert credentials set
cde47b
@@ -86,7 +85,7 @@ static int _gnutls_server_cert_type_recv_params(gnutls_session_t session,
cde47b
 
cde47b
 		/* Compare packet length with expected packet length. For the
cde47b
 		 * client this is a single byte. */
cde47b
-		if (len != 1) {
cde47b
+		if (data_size != 1) {
cde47b
 			return
cde47b
 					gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cde47b
 		}
cde47b
@@ -135,8 +134,8 @@ static int _gnutls_server_cert_type_recv_params(gnutls_session_t session,
cde47b
 
cde47b
 	} else {		// server mode
cde47b
 		// Compare packet length with expected packet length.
cde47b
-		DECR_LEN(len, 1);
cde47b
-		if (data[0] != len) {
cde47b
+		DECR_LEN(data_size, 1);
cde47b
+		if (data[0] != data_size) {
cde47b
 			return
cde47b
 					gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cde47b
 		}
cde47b
@@ -144,7 +143,7 @@ static int _gnutls_server_cert_type_recv_params(gnutls_session_t session,
cde47b
 
cde47b
 		// Assign the contents of our data buffer to a gnutls_datum_t
cde47b
 		cert_types.data = (uint8_t*)pdata; // Need casting to get rid of 'discards const qualifier' warning
cde47b
-		cert_types.size = len;
cde47b
+		cert_types.size = data_size;
cde47b
 
cde47b
 		// Store the server certificate types in our session
cde47b
 		_gnutls_hello_ext_set_datum(session,
cde47b
diff --git a/lib/ext/server_name.c b/lib/ext/server_name.c
cde47b
index 259dc998e..0c6331569 100644
cde47b
--- a/lib/ext/server_name.c
cde47b
+++ b/lib/ext/server_name.c
cde47b
@@ -66,11 +66,10 @@ const hello_ext_entry_st ext_mod_server_name = {
cde47b
  */
cde47b
 static int
cde47b
 _gnutls_server_name_recv_params(gnutls_session_t session,
cde47b
-				const uint8_t * data, size_t _data_size)
cde47b
+				const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	const unsigned char *p;
cde47b
 	uint16_t len, type;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	gnutls_datum_t name;
cde47b
 
cde47b
 	if (session->security_parameters.entity == GNUTLS_SERVER) {
cde47b
diff --git a/lib/ext/session_ticket.c b/lib/ext/session_ticket.c
cde47b
index 98db39ff8..263273fa2 100644
cde47b
--- a/lib/ext/session_ticket.c
cde47b
+++ b/lib/ext/session_ticket.c
cde47b
@@ -78,7 +78,7 @@ static int
cde47b
 unpack_ticket(const gnutls_datum_t *ticket_data, struct ticket_st *ticket)
cde47b
 {
cde47b
 	const uint8_t * data = ticket_data->data;
cde47b
-	ssize_t data_size = ticket_data->size;
cde47b
+	size_t data_size = ticket_data->size;
cde47b
 	const uint8_t *encrypted_state;
cde47b
 
cde47b
 	/* Format:
cde47b
@@ -371,11 +371,10 @@ unpack_session(gnutls_session_t session, const gnutls_datum_t *state)
cde47b
 
cde47b
 static int
cde47b
 session_ticket_recv_params(gnutls_session_t session,
cde47b
-			   const uint8_t * data, size_t _data_size)
cde47b
+			   const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	gnutls_datum_t ticket_data;
cde47b
 	gnutls_datum_t state;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	int ret;
cde47b
 
cde47b
 	if (session->internals.flags & GNUTLS_NO_TICKETS)
cde47b
diff --git a/lib/ext/signature.c b/lib/ext/signature.c
cde47b
index e734d2c7d..a90f58d53 100644
cde47b
--- a/lib/ext/signature.c
cde47b
+++ b/lib/ext/signature.c
cde47b
@@ -187,9 +187,8 @@ _gnutls_sign_algorithm_parse_data(gnutls_session_t session,
cde47b
 static int
cde47b
 _gnutls_signature_algorithm_recv_params(gnutls_session_t session,
cde47b
 					const uint8_t * data,
cde47b
-					size_t _data_size)
cde47b
+					size_t data_size)
cde47b
 {
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	int ret;
cde47b
 
cde47b
 	if (session->security_parameters.entity == GNUTLS_CLIENT) {
cde47b
diff --git a/lib/ext/srp.c b/lib/ext/srp.c
cde47b
index 8b58222e0..07f6e6883 100644
cde47b
--- a/lib/ext/srp.c
cde47b
+++ b/lib/ext/srp.c
cde47b
@@ -59,10 +59,9 @@ const hello_ext_entry_st ext_mod_srp = {
cde47b
 
cde47b
 static int
cde47b
 _gnutls_srp_recv_params(gnutls_session_t session, const uint8_t * data,
cde47b
-			size_t _data_size)
cde47b
+			size_t data_size)
cde47b
 {
cde47b
 	uint8_t len;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	gnutls_ext_priv_data_t epriv;
cde47b
 	srp_ext_st *priv;
cde47b
 
cde47b
diff --git a/lib/ext/srtp.c b/lib/ext/srtp.c
cde47b
index 3fc7ed35a..412e26d45 100644
cde47b
--- a/lib/ext/srtp.c
cde47b
+++ b/lib/ext/srtp.c
cde47b
@@ -162,13 +162,12 @@ const char *gnutls_srtp_get_profile_name(gnutls_srtp_profile_t profile)
cde47b
 
cde47b
 static int
cde47b
 _gnutls_srtp_recv_params(gnutls_session_t session,
cde47b
-			 const uint8_t * data, size_t _data_size)
cde47b
+			 const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	unsigned int i;
cde47b
 	int ret;
cde47b
 	const uint8_t *p = data;
cde47b
-	int len;
cde47b
-	ssize_t data_size = _data_size;
cde47b
+	size_t len;
cde47b
 	srtp_ext_st *priv;
cde47b
 	gnutls_ext_priv_data_t epriv;
cde47b
 	uint16_t profile;
cde47b
diff --git a/lib/ext/status_request.c b/lib/ext/status_request.c
cde47b
index d8779e8cf..cf9d5bd03 100644
cde47b
--- a/lib/ext/status_request.c
cde47b
+++ b/lib/ext/status_request.c
cde47b
@@ -86,9 +86,8 @@ client_send(gnutls_session_t session,
cde47b
 static int
cde47b
 server_recv(gnutls_session_t session,
cde47b
 	    status_request_ext_st * priv,
cde47b
-	    const uint8_t * data, size_t size)
cde47b
+	    const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
-	ssize_t data_size = size;
cde47b
 	unsigned rid_bytes = 0;
cde47b
 
cde47b
 	/* minimum message is type (1) + responder_id_list (2) +
cde47b
diff --git a/lib/ext/supported_groups.c b/lib/ext/supported_groups.c
cde47b
index 952d3bb0c..ef7859f73 100644
cde47b
--- a/lib/ext/supported_groups.c
cde47b
+++ b/lib/ext/supported_groups.c
cde47b
@@ -93,10 +93,9 @@ static unsigned get_min_dh(gnutls_session_t session)
cde47b
  */
cde47b
 static int
cde47b
 _gnutls_supported_groups_recv_params(gnutls_session_t session,
cde47b
-				  const uint8_t * data, size_t _data_size)
cde47b
+				  const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	int i;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	uint16_t len;
cde47b
 	const uint8_t *p = data;
cde47b
 	const gnutls_group_entry_st *group = NULL;
cde47b
diff --git a/lib/ext/supported_versions.c b/lib/ext/supported_versions.c
cde47b
index 52828ee37..8d52fad5c 100644
cde47b
--- a/lib/ext/supported_versions.c
cde47b
+++ b/lib/ext/supported_versions.c
cde47b
@@ -54,12 +54,11 @@ const hello_ext_entry_st ext_mod_supported_versions = {
cde47b
 
cde47b
 static int
cde47b
 supported_versions_recv_params(gnutls_session_t session,
cde47b
-			       const uint8_t * data, size_t _data_size)
cde47b
+			       const uint8_t * data, size_t data_size)
cde47b
 {
cde47b
 	const version_entry_st *vers;
cde47b
-	ssize_t data_size = _data_size;
cde47b
 	uint8_t major, minor;
cde47b
-	ssize_t bytes;
cde47b
+	size_t bytes;
cde47b
 	int ret;
cde47b
 
cde47b
 	if (session->security_parameters.entity == GNUTLS_SERVER) {
cde47b
diff --git a/lib/extv.c b/lib/extv.c
cde47b
index bfdfdf974..0c0c46f32 100644
cde47b
--- a/lib/extv.c
cde47b
+++ b/lib/extv.c
cde47b
@@ -105,7 +105,7 @@ int gnutls_ext_raw_parse(void *ctx, gnutls_ext_raw_process_func cb,
cde47b
 			 const gnutls_datum_t *data, unsigned int flags)
cde47b
 {
cde47b
 	if (flags & GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO) {
cde47b
-		ssize_t size = data->size;
cde47b
+		size_t size = data->size;
cde47b
 		size_t len;
cde47b
 		uint8_t *p = data->data;
cde47b
 
cde47b
@@ -137,12 +137,12 @@ int gnutls_ext_raw_parse(void *ctx, gnutls_ext_raw_process_func cb,
cde47b
 		DECR_LEN(size, len);
cde47b
 		p += len;
cde47b
 
cde47b
-		if (size <= 0)
cde47b
+		if (size == 0)
cde47b
 			return gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
cde47b
 
cde47b
 		return _gnutls_extv_parse(ctx, cb, p, size);
cde47b
 	} else if (flags & GNUTLS_EXT_RAW_FLAG_DTLS_CLIENT_HELLO) {
cde47b
-		ssize_t size = data->size;
cde47b
+		size_t size = data->size;
cde47b
 		size_t len;
cde47b
 		uint8_t *p = data->data;
cde47b
 
cde47b
@@ -181,7 +181,7 @@ int gnutls_ext_raw_parse(void *ctx, gnutls_ext_raw_process_func cb,
cde47b
 		DECR_LEN(size, len);
cde47b
 		p += len;
cde47b
 
cde47b
-		if (size <= 0)
cde47b
+		if (size == 0)
cde47b
 			return gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
cde47b
 
cde47b
 		return _gnutls_extv_parse(ctx, cb, p, size);
cde47b
diff --git a/lib/sslv2_compat.c b/lib/sslv2_compat.c
cde47b
index 6122d1098..9d247ba4c 100644
cde47b
--- a/lib/sslv2_compat.c
cde47b
+++ b/lib/sslv2_compat.c
cde47b
@@ -87,14 +87,13 @@ _gnutls_handshake_select_v2_suite(gnutls_session_t session,
cde47b
  */
cde47b
 int
cde47b
 _gnutls_read_client_hello_v2(gnutls_session_t session, uint8_t * data,
cde47b
-			     unsigned int datalen)
cde47b
+			     unsigned int len)
cde47b
 {
cde47b
 	uint16_t session_id_len = 0;
cde47b
 	int pos = 0;
cde47b
 	int ret = 0, sret = 0;
cde47b
 	uint16_t sizeOfSuites;
cde47b
 	uint8_t rnd[GNUTLS_RANDOM_SIZE], major, minor;
cde47b
-	int len = datalen;
cde47b
 	int neg_version;
cde47b
 	const version_entry_st *vers;
cde47b
 	uint16_t challenge;
cde47b
diff --git a/lib/supplemental.c b/lib/supplemental.c
cde47b
index cd90fa1fb..07b38cc93 100644
cde47b
--- a/lib/supplemental.c
cde47b
+++ b/lib/supplemental.c
cde47b
@@ -192,14 +192,14 @@ _gnutls_parse_supplemental(gnutls_session_t session,
cde47b
 			   const uint8_t * data, int datalen)
cde47b
 {
cde47b
 	const uint8_t *p = data;
cde47b
-	ssize_t dsize = datalen;
cde47b
+	size_t dsize = datalen;
cde47b
 	size_t total_size;
cde47b
 
cde47b
 	DECR_LEN(dsize, 3);
cde47b
 	total_size = _gnutls_read_uint24(p);
cde47b
 	p += 3;
cde47b
 
cde47b
-	if (dsize != (ssize_t) total_size) {
cde47b
+	if (dsize != total_size) {
cde47b
 		gnutls_assert();
cde47b
 		return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
cde47b
 	}
cde47b
diff --git a/lib/tls13/certificate.c b/lib/tls13/certificate.c
cde47b
index bd257237f..8a1a11872 100644
cde47b
--- a/lib/tls13/certificate.c
cde47b
+++ b/lib/tls13/certificate.c
cde47b
@@ -360,11 +360,12 @@ static int parse_cert_extension(void *_ctx, unsigned tls_id, const uint8_t *data
cde47b
 static int
cde47b
 parse_cert_list(gnutls_session_t session, uint8_t * data, size_t data_size)
cde47b
 {
cde47b
-	int len, ret;
cde47b
+	int ret;
cde47b
+	size_t len;
cde47b
 	uint8_t *p = data;
cde47b
 	cert_auth_info_t info;
cde47b
 	gnutls_certificate_credentials_t cred;
cde47b
-	ssize_t dsize = data_size, size;
cde47b
+	size_t size;
cde47b
 	int i;
cde47b
 	unsigned npeer_certs, npeer_ocsp, j;
cde47b
 	crt_cert_ctx_st ctx;
cde47b
@@ -395,31 +396,31 @@ parse_cert_list(gnutls_session_t session, uint8_t * data, size_t data_size)
cde47b
 	if (info == NULL)
cde47b
 		return gnutls_assert_val(GNUTLS_E_INSUFFICIENT_CREDENTIALS);
cde47b
 
cde47b
-	DECR_LEN(dsize, 3);
cde47b
+	DECR_LEN(data_size, 3);
cde47b
 	size = _gnutls_read_uint24(p);
cde47b
 	p += 3;
cde47b
 
cde47b
-	if (size != dsize)
cde47b
+	if (size != data_size)
cde47b
 		return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cde47b
 
cde47b
 	if (size == 0)
cde47b
 		return gnutls_assert_val(GNUTLS_E_NO_CERTIFICATE_FOUND);
cde47b
 
cde47b
-	i = dsize;
cde47b
+	i = data_size;
cde47b
 
cde47b
 	while (i > 0) {
cde47b
-		DECR_LEN(dsize, 3);
cde47b
+		DECR_LEN(data_size, 3);
cde47b
 		len = _gnutls_read_uint24(p);
cde47b
 		if (len == 0)
cde47b
 			return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cde47b
 
cde47b
-		DECR_LEN(dsize, len);
cde47b
+		DECR_LEN(data_size, len);
cde47b
 		p += len + 3;
cde47b
 		i -= len + 3;
cde47b
 
cde47b
-		DECR_LEN(dsize, 2);
cde47b
+		DECR_LEN(data_size, 2);
cde47b
 		len = _gnutls_read_uint16(p);
cde47b
-		DECR_LEN(dsize, len);
cde47b
+		DECR_LEN(data_size, len);
cde47b
 
cde47b
 		i -= len + 2;
cde47b
 		p += len + 2;
cde47b
@@ -427,7 +428,7 @@ parse_cert_list(gnutls_session_t session, uint8_t * data, size_t data_size)
cde47b
 		nentries++;
cde47b
 	}
cde47b
 
cde47b
-	if (dsize != 0)
cde47b
+	if (data_size != 0)
cde47b
 		return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cde47b
 
cde47b
 	/* this is unnecessary - keeping to avoid a regression due to a re-org
cde47b
diff --git a/lib/tls13/psk_ext_parser.c b/lib/tls13/psk_ext_parser.c
cde47b
index 6e3a12f90..33ebc0461 100644
cde47b
--- a/lib/tls13/psk_ext_parser.c
cde47b
+++ b/lib/tls13/psk_ext_parser.c
cde47b
@@ -28,10 +28,8 @@
cde47b
  * are present, or 0, on success.
cde47b
  */
cde47b
 int _gnutls13_psk_ext_parser_init(psk_ext_parser_st *p,
cde47b
-				  const unsigned char *data, size_t _len)
cde47b
+				  const unsigned char *data, size_t len)
cde47b
 {
cde47b
-	ssize_t len = _len;
cde47b
-
cde47b
 	if (!p || !data || !len)
cde47b
 		return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
cde47b
 
cde47b
diff --git a/lib/tls13/psk_ext_parser.h b/lib/tls13/psk_ext_parser.h
cde47b
index 30b47e904..f46b211e0 100644
cde47b
--- a/lib/tls13/psk_ext_parser.h
cde47b
+++ b/lib/tls13/psk_ext_parser.h
cde47b
@@ -25,10 +25,10 @@
cde47b
 
cde47b
 struct psk_ext_parser_st {
cde47b
 	const unsigned char *identities_data;
cde47b
-	ssize_t identities_len;
cde47b
+	size_t identities_len;
cde47b
 
cde47b
 	const unsigned char *binders_data;
cde47b
-	ssize_t binders_len;
cde47b
+	size_t binders_len;
cde47b
 };
cde47b
 
cde47b
 typedef struct psk_ext_parser_st psk_ext_parser_st;
cde47b
diff --git a/lib/tls13/session_ticket.c b/lib/tls13/session_ticket.c
cde47b
index 146aee9b1..072a56d9c 100644
cde47b
--- a/lib/tls13/session_ticket.c
cde47b
+++ b/lib/tls13/session_ticket.c
cde47b
@@ -105,7 +105,7 @@ unpack_ticket(gnutls_session_t session, gnutls_datum_t *packed, tls13_ticket_st
cde47b
 	gnutls_mac_algorithm_t kdf;
cde47b
 	const mac_entry_st *prf;
cde47b
 	uint8_t *p;
cde47b
-	ssize_t len;
cde47b
+	size_t len;
cde47b
 	uint64_t v;
cde47b
 	int ret;
cde47b
 
cde47b
-- 
cde47b
2.21.0
cde47b