@@ -30,10 +30,10 @@ index 8e9b110bb3..3a2407b0e4 100644
30
30
# define TLSEXT_TYPE_compress_certificate 27
31
31
32
32
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
33
- index 295b719ff2..429d710fa2 100644
33
+ index 295b719ff2..3d92df0db1 100644
34
34
--- a/ssl/ssl_lib.c
35
35
+++ b/ssl/ssl_lib.c
36
- @@ -6641,6 +6641,101 @@ int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen)
36
+ @@ -6641,6 +6641,106 @@ int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen)
37
37
return 0;
38
38
}
39
39
@@ -59,15 +59,18 @@ index 295b719ff2..429d710fa2 100644
59
59
+ *(uint16_t *) ptr = (uint16_t) sc->clienthello->legacy_version;
60
60
+ ptr += sizeof(uint16_t);
61
61
+
62
+ + /* ciphers */
62
63
+ num = PACKET_remaining(&sc->clienthello->ciphersuites);
63
- + *(uint16_t *) ptr = (uint16_t) num;
64
- + ptr += sizeof(uint16_t);
64
+ + if (ossl_likely(num > 0)) {
65
+ + *(uint16_t *) ptr = (uint16_t) num;
66
+ + ptr += sizeof(uint16_t);
65
67
+
66
- + if (ossl_unlikely(ptr + num > end))
67
- + return 0;
68
+ + if (ossl_unlikely(ptr + num > end))
69
+ + return 0;
68
70
+
69
- + memcpy(ptr, PACKET_data(&sc->clienthello->ciphersuites), num);
70
- + ptr += num;
71
+ + memcpy(ptr, PACKET_data(&sc->clienthello->ciphersuites), num);
72
+ + ptr += num;
73
+ + }
71
74
+
72
75
+ /* extensions */
73
76
+ num = 0;
@@ -99,9 +102,11 @@ index 295b719ff2..429d710fa2 100644
99
102
+ }
100
103
+
101
104
+ ptr += num;
102
- + /* groups */
103
- + if (groups) {
104
- + num = PACKET_remaining(groups);
105
+ +
106
+ + /* groups */
107
+ + num = PACKET_remaining(groups);
108
+ + if (groups && num > 0) {
109
+ +
105
110
+ if (ossl_unlikely((ptr + num + sizeof(uint16_t)) > end))
106
111
+ return 0;
107
112
+ memcpy(ptr, PACKET_data(groups), num);
@@ -115,8 +120,8 @@ index 295b719ff2..429d710fa2 100644
115
120
+ }
116
121
+
117
122
+ /* formats */
118
- + if (formats) {
119
- + num = PACKET_remaining(formats);
123
+ + num = PACKET_remaining (formats);
124
+ + if (formats && num > 0) {
120
125
+ if (ossl_unlikely((ptr + num + sizeof(uint8_t)) > end))
121
126
+ return 0;
122
127
+ memcpy(ptr, PACKET_data(formats), num);
0 commit comments