Fix no-psk
[openssl.git] / apps / s_client.c
index 3ecc60188344268943d134e48b1a303fba09473a..e180772e7f78d65b6ed483cbf2cc6ac6c2da5c34 100644 (file)
@@ -2359,7 +2359,9 @@ int s_client_main(int argc, char **argv)
         break;
     }
 
-    if (early_data_file != NULL) {
+    if (early_data_file != NULL
+            && SSL_get0_session(con) != NULL
+            && SSL_SESSION_get_max_early_data(SSL_get0_session(con)) > 0) {
         BIO *edfile = BIO_new_file(early_data_file, "r");
         size_t readbytes, writtenbytes;
         int finish = 0;
@@ -2373,9 +2375,7 @@ int s_client_main(int argc, char **argv)
             if (!BIO_read_ex(edfile, cbuf, BUFSIZZ, &readbytes))
                 finish = 1;
 
-            while (finish ? !SSL_write_early_finish(con)
-                          : !SSL_write_early(con, cbuf, readbytes,
-                                             &writtenbytes)) {
+            while (!SSL_write_early_data(con, cbuf, readbytes, &writtenbytes)) {
                 switch (SSL_get_error(con, 0)) {
                 case SSL_ERROR_WANT_WRITE:
                 case SSL_ERROR_WANT_ASYNC:
@@ -3091,6 +3091,8 @@ static int ldap_ExtendedResponse_parse(const char *buf, long rem)
         goto end;
     }
 
+    rem = len;  /* ensure that we don't overstep the SEQUENCE */
+
     /* pull MessageID */
     inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
     if (inf != V_ASN1_UNIVERSAL || tag != V_ASN1_INTEGER ||