Ensure that we write out alerts correctly after early_data
[oweals/openssl.git] / ssl / record / ssl3_record_tls13.c
index 8822ca25c36976a3c3ef088c8719fb2951306b08..cbf6a652e7050c06f0fa91f9eea50caa3f817715 100644 (file)
@@ -52,7 +52,10 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending)
         seq = RECORD_LAYER_get_read_sequence(&s->rlayer);
     }
 
-    if (ctx == NULL) {
+    if (ctx == NULL
+            || (rec->type == SSL3_RT_ALERT
+                && s->statem.enc_write_state
+                   == ENC_WRITE_STATE_WRITE_PLAIN_ALERTS)) {
         memmove(rec->data, rec->input, rec->length);
         rec->input = rec->data;
         return 1;