Make sure to NUL-terminate the string on end-of-file (and error)
[openssl.git] / crypto / bio / bss_bio.c
index 1eeed9e7fef67ab6dd45108220089a7b32571bbe..aa58dab046b2e90a1cf59f69c9b68fd670f1adac 100644 (file)
@@ -7,9 +7,18 @@
  * for which no specific BIO method is available.
  * See ssl/ssltest.c for some hints on how this can be used. */
 
+/* BIO_DEBUG implies BIO_PAIR_DEBUG */
+#ifdef BIO_DEBUG
+# ifndef BIO_PAIR_DEBUG
+#  define BIO_PAIR_DEBUG
+# endif
+#endif
+
+/* disable assert() unless BIO_PAIR_DEBUG has been defined */
 #ifndef BIO_PAIR_DEBUG
-# undef NDEBUG /* avoid conflicting definitions */
-# define NDEBUG
+# ifndef NDEBUG
+#  define NDEBUG
+# endif
 #endif
 
 #include <assert.h>
 
 #include <openssl/bio.h>
 #include <openssl/err.h>
-#include <openssl/err.h>
 #include <openssl/crypto.h>
 
 #include "e_os.h"
 
 /* VxWorks defines SSIZE_MAX with an empty value causing compile errors */
-#if defined(OPENSSL_SYS_VSWORKS)
+#if defined(OPENSSL_SYS_VXWORKS)
 # undef SSIZE_MAX
 #endif
 #ifndef SSIZE_MAX
@@ -260,7 +268,7 @@ static ssize_t bio_nread(BIO *bio, char **buf, size_t num_)
        ssize_t num, available;
 
        if (num_ > SSIZE_MAX)
-                num = SSIZE_MAX;
+               num = SSIZE_MAX;
        else
                num = (ssize_t)num_;