use BIO_nwrite() more properly to demonstrate the general idea of
authorBodo Möller <bodo@openssl.org>
Thu, 14 Mar 2002 09:49:10 +0000 (09:49 +0000)
committerBodo Möller <bodo@openssl.org>
Thu, 14 Mar 2002 09:49:10 +0000 (09:49 +0000)
BIO_nwrite0/BIO_nwrite (the previous code was OK for BIO pairs but not
in general)

ssl/ssltest.c

index 2ef8a50785b77775f84e074349dc76e36b4e9940..ebd3b527df11457631d4d14cd0aa20cd1237c146 100644 (file)
@@ -848,10 +848,10 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
                                        if (num > 1)
                                                --num; /* test restartability even more thoroughly */
                                        
-                                       r = BIO_nwrite(io1, &dataptr, (int)num);
+                                       r = BIO_nwrite0(io1, &dataptr);
                                        assert(r > 0);
-                                       assert(r <= (int)num);
-                                       num = r;
+                                       if (r < num)
+                                               num = r;
                                        r = BIO_read(io2, dataptr, (int)num);
                                        if (r != (int)num) /* can't happen */
                                                {
@@ -860,6 +860,13 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
                                                goto err;
                                                }
                                        progress = 1;
+                                       r = BIO_nwrite(io1, &dataptr, (int)num);
+                                       if (r != (int)num) /* can't happen */
+                                               {
+                                               fprintf(stderr, "ERROR: BIO_nwrite() did not accept "
+                                                       "BIO_nwrite0() bytes");
+                                               goto err;
+                                               }
                                        
                                        if (debug)
                                                printf((io2 == client_io) ?