Avoid issues with endianness when type is used in SSL_trace()
authorTomas Mraz <tomas@openssl.org>
Wed, 23 Aug 2023 16:12:32 +0000 (18:12 +0200)
committerHugo Landau <hlandau@openssl.org>
Fri, 25 Aug 2023 11:03:46 +0000 (12:03 +0100)
The TLS record type is a single byte value so we can
use uint8_t for it. This allows passing its address
directly to SSL_trace() instead of converting it to
a single byte type first.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21823)

doc/designs/quic-design/record-layer.md
include/internal/recordmethod.h
ssl/quic/quic_tls.c
ssl/record/methods/recmethod_local.h
ssl/record/methods/tls_common.c
ssl/record/record.h

index da424064a38ce3bb1ae838fd6533c8ce601f260e..8db4b319c54297c9ca93335284e6ea5e2ef69e50 100644 (file)
@@ -507,7 +507,7 @@ struct ossl_record_method_st {
      * multiple records in one go and buffer them.
      */
     int (*read_record)(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion,
-                      int *type, unsigned char **data, size_t *datalen,
+                      uint8_t *type, unsigned char **data, size_t *datalen,
                       uint16_t *epoch, unsigned char *seq_num);
     /*
      * Release a buffer associated with a record previously read with
index 247c24f032440c0a81674b5dd3d0eddc2ee76246..c49b5da4ee5b452fb745eb878164d5c2a20a2153 100644 (file)
@@ -232,7 +232,7 @@ struct ossl_record_method_st {
      * multiple records in one go and buffer them.
      */
     int (*read_record)(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion,
-                      int *type, const unsigned char **data, size_t *datalen,
+                      uint8_t *type, const unsigned char **data, size_t *datalen,
                       uint16_t *epoch, unsigned char *seq_num);
     /*
      * Release length bytes from a buffer associated with a record previously
index 8f104f63e3feae370504f2b9775f57ad83725bc6..14b23baeb270163c39c59b65fc1ca616ba4cf83e 100644 (file)
@@ -356,7 +356,7 @@ static int quic_retry_write_records(OSSL_RECORD_LAYER *rl)
 }
 
 static int quic_read_record(OSSL_RECORD_LAYER *rl, void **rechandle,
-                            int *rversion, int *type, const unsigned char **data,
+                            int *rversion, uint8_t *type, const unsigned char **data,
                             size_t *datalen, uint16_t *epoch,
                             unsigned char *seq_num)
 {
index b5dfaf30d284583a68eccf466e6150b0741e914c..cf0af62f3a19c61d1e5daf019dcb568d46308ea4 100644 (file)
@@ -459,7 +459,7 @@ int tls_retry_write_records(OSSL_RECORD_LAYER *rl);
 int tls_get_alert_code(OSSL_RECORD_LAYER *rl);
 int tls_set1_bio(OSSL_RECORD_LAYER *rl, BIO *bio);
 int tls_read_record(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion,
-                    int *type, const unsigned char **data, size_t *datalen,
+                    uint8_t *type, const unsigned char **data, size_t *datalen,
                     uint16_t *epoch, unsigned char *seq_num);
 int tls_release_record(OSSL_RECORD_LAYER *rl, void *rechandle, size_t length);
 int tls_default_set_protocol_version(OSSL_RECORD_LAYER *rl, int version);
index 505e13316180bf0a32406a3576b49a5571368995..576b651aa7c138b4c53d57e1ce7bbf41c896c5df 100644 (file)
@@ -1088,7 +1088,7 @@ int tls13_common_post_process_record(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *rec)
 }
 
 int tls_read_record(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion,
-                    int *type, const unsigned char **data, size_t *datalen,
+                    uint8_t *type, const unsigned char **data, size_t *datalen,
                     uint16_t *epoch, unsigned char *seq_num)
 {
     TLS_RL_RECORD *rec;
index 7dcbbb36e90dd981434d22ab4bdf49dd10b2a6ad..a8fa6833e90f82b6d172ee99ddde0acf9f56aec9 100644 (file)
@@ -22,7 +22,7 @@
 typedef struct tls_record_st {
     void *rechandle;
     int version;
-    int type;
+    uint8_t type;
     /* The data buffer containing bytes from the record */
     const unsigned char *data;
     /*