Fix some undefined behaviour in stack test
[openssl.git] / test / sslapitest.c
index 1cd850c1ce54359d2dad4b7932643c0b0eb0e2e0..85fcabc66c930a2f10e4c8c6c270c3023bbaeb83 100644 (file)
@@ -1604,7 +1604,7 @@ static int test_early_data_read_write(void)
         goto end;
 
     /* Write and read some early data */
-    if (!SSL_write_early(clientssl, MSG1, strlen(MSG1), &written)
+    if (!SSL_write_early_data(clientssl, MSG1, strlen(MSG1), &written)
             || written != strlen(MSG1)) {
         printf("Failed writing early data message 1\n");
         goto end;
@@ -1624,10 +1624,10 @@ static int test_early_data_read_write(void)
     }
 
     /*
-     * Server should be able to write normal data, and client should be able to
+     * Server should be able to write data, and client should be able to
      * read it.
      */
-    if (!SSL_write_ex(serverssl, MSG2, strlen(MSG2), &written)
+    if (!SSL_write_early_data(serverssl, MSG2, strlen(MSG2), &written)
             || written != strlen(MSG2)) {
         printf("Failed writing message 2\n");
         goto end;
@@ -1641,13 +1641,13 @@ static int test_early_data_read_write(void)
     }
 
     /* Even after reading normal data, client should be able write early data */
-    if (!SSL_write_early(clientssl, MSG3, strlen(MSG3), &written)
+    if (!SSL_write_early_data(clientssl, MSG3, strlen(MSG3), &written)
             || written != strlen(MSG3)) {
         printf("Failed writing early data message 3\n");
         goto end;
     }
 
-    /* Server should still be able read early data after writing normal data */
+    /* Server should still be able read early data after writing data */
     if (SSL_read_early_data(serverssl, buf, sizeof(buf), &readbytes)
                 != SSL_READ_EARLY_DATA_SUCCESS
             || readbytes != strlen(MSG3)
@@ -1656,8 +1656,8 @@ static int test_early_data_read_write(void)
         goto end;
     }
 
-    /* Write more normal data from server and read it from client */
-    if (!SSL_write_ex(serverssl, MSG4, strlen(MSG4), &written)
+    /* Write more data from server and read it from client */
+    if (!SSL_write_early_data(serverssl, MSG4, strlen(MSG4), &written)
             || written != strlen(MSG4)) {
         printf("Failed writing message 4\n");
         goto end;
@@ -1700,8 +1700,8 @@ static int test_early_data_read_write(void)
         goto end;
     }
 
-    /* Client and server should not be able to write early data now */
-    if (SSL_write_early(clientssl, MSG6, strlen(MSG6), &written)) {
+    /* Client and server should not be able to write/read early data now */
+    if (SSL_write_early_data(clientssl, MSG6, strlen(MSG6), &written)) {
         printf("Unexpected success writing early data\n");
         goto end;
     }
@@ -1745,7 +1745,7 @@ static int test_early_data_read_write(void)
     }
 
     /* Write and read some early data */
-    if (!SSL_write_early(clientssl, MSG1, strlen(MSG1), &written)
+    if (!SSL_write_early_data(clientssl, MSG1, strlen(MSG1), &written)
             || written != strlen(MSG1)) {
         printf("Failed writing early data message 1\n");
         goto end;
@@ -1764,22 +1764,13 @@ static int test_early_data_read_write(void)
         goto end;
     }
 
-    /*
-     * We expect SSL_accept() to initially block as it handles the end of early
-     * data alert
-     */
-    if (SSL_accept(serverssl) > 0) {
-        printf("Unexpected success completing server handshake\n");
-        goto end;
-    }
-
     if (SSL_accept(serverssl) <= 0) {
         printf("Unable to complete server handshake\n");
         goto end;
     }
 
-    /* Client and server should not be able to write early data now */
-    if (SSL_write_early(clientssl, MSG6, strlen(MSG6), &written)) {
+    /* Client and server should not be able to write/read early data now */
+    if (SSL_write_early_data(clientssl, MSG6, strlen(MSG6), &written)) {
         printf("Unexpected success writing early data (2)\n");
         goto end;
     }
@@ -1847,7 +1838,7 @@ static int test_early_data_skip(void)
     }
 
     /* Write some early data */
-    if (!SSL_write_early(clientssl, MSG1, strlen(MSG1), &written)
+    if (!SSL_write_early_data(clientssl, MSG1, strlen(MSG1), &written)
             || written != strlen(MSG1)) {
         printf("Failed writing early data message 1\n");
         goto end;
@@ -2008,7 +1999,7 @@ static int test_early_data_not_expected(void)
         goto end;
 
     /* Write some early data */
-    if (!SSL_write_early(clientssl, MSG1, strlen(MSG1), &written)) {
+    if (!SSL_write_early_data(clientssl, MSG1, strlen(MSG1), &written)) {
         printf("Unexpected failure writing message 1\n");
         goto end;
     }