@@ -242,6 +242,7 @@ void EncryptedPreMasterSecret::read(SSL& ssl, input_buffer& input)
242242 }
243243
244244 opaque preMasterSecret[SECRET_LEN];
245+ memset (preMasterSecret, 0 , sizeof (preMasterSecret));
245246 rsa.decrypt (preMasterSecret, secret_, length_,
246247 ssl.getCrypto ().get_random ());
247248
@@ -300,6 +301,11 @@ void ClientDiffieHellmanPublic::read(SSL& ssl, input_buffer& input)
300301 tmp[1 ] = input[AUTO];
301302 ato16 (tmp, keyLength);
302303
304+ if (keyLength < dh.get_agreedKeyLength ()/2 ) {
305+ ssl.SetError (bad_input);
306+ return ;
307+ }
308+
303309 alloc (keyLength);
304310 input.read (Yc_, keyLength);
305311 if (input.get_error ()) {
@@ -408,6 +414,10 @@ void DH_Server::read(SSL& ssl, input_buffer& input)
408414 tmp[1 ] = input[AUTO];
409415 ato16 (tmp, length);
410416
417+ if (length == 0 ) {
418+ ssl.SetError (bad_input);
419+ return ;
420+ }
411421 signature_ = NEW_YS byte[length];
412422 input.read (signature_, length);
413423 if (input.get_error ()) {
@@ -864,6 +874,12 @@ void ChangeCipherSpec::Process(input_buffer& input, SSL& ssl)
864874 return ;
865875 }
866876
877+ // detect duplicate change_cipher
878+ if (ssl.getSecurity ().get_parms ().pending_ == false ) {
879+ ssl.order_error ();
880+ return ;
881+ }
882+
867883 ssl.useSecurity ().use_parms ().pending_ = false ;
868884 if (ssl.getSecurity ().get_resuming ()) {
869885 if (ssl.getSecurity ().get_parms ().entity_ == client_end)
@@ -2047,12 +2063,8 @@ input_buffer& operator>>(input_buffer& input, CertificateRequest& request)
20472063 tmp[0 ] = input[AUTO];
20482064 tmp[1 ] = input[AUTO];
20492065 ato16 (tmp, dnSz);
2050-
2051- DistinguishedName dn;
2052- request.certificate_authorities_ .push_back (dn = NEW_YS
2053- byte[REQUEST_HEADER + dnSz]);
2054- memcpy (dn, tmp, REQUEST_HEADER);
2055- input.read (&dn[REQUEST_HEADER], dnSz);
2066+
2067+ input.set_current (input.get_current () + dnSz);
20562068
20572069 sz -= dnSz + REQUEST_HEADER;
20582070
@@ -2191,6 +2203,11 @@ input_buffer& operator>>(input_buffer& input, CertificateVerify& request)
21912203 ato16 (tmp, sz);
21922204 request.set_length (sz);
21932205
2206+ if (sz == 0 ) {
2207+ input.set_error ();
2208+ return input;
2209+ }
2210+
21942211 request.signature_ = NEW_YS byte[sz];
21952212 input.read (request.signature_ , sz);
21962213
0 commit comments