Remove /* foo.c */ comments
[oweals/openssl.git] / crypto / bio / bf_nbio.c
index 3af58bd38f4cd7da4139de3e66a877d5e434dc2e..e78bca50597c0ec81f56f71b57f999345a9b71c5 100644 (file)
@@ -1,4 +1,3 @@
-/* crypto/bio/bf_nbio.c */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -58,7 +57,7 @@
 
 #include <stdio.h>
 #include <errno.h>
-#include "cryptlib.h"
+#include "internal/cryptlib.h"
 #include <openssl/rand.h>
 #include <openssl/bio.h>
 
@@ -102,13 +101,12 @@ static int nbiof_new(BIO *bi)
 {
     NBIO_TEST *nt;
 
-    if (!(nt = (NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST))))
+    if ((nt = OPENSSL_zalloc(sizeof(*nt))) == NULL)
         return (0);
     nt->lrn = -1;
     nt->lwn = -1;
     bi->ptr = (char *)nt;
     bi->init = 1;
-    bi->flags = 0;
     return (1);
 }
 
@@ -116,8 +114,7 @@ static int nbiof_free(BIO *a)
 {
     if (a == NULL)
         return (0);
-    if (a->ptr != NULL)
-        OPENSSL_free(a->ptr);
+    OPENSSL_free(a->ptr);
     a->ptr = NULL;
     a->init = 0;
     a->flags = 0;
@@ -136,7 +133,8 @@ static int nbiof_read(BIO *b, char *out, int outl)
         return (0);
 
     BIO_clear_retry_flags(b);
-    RAND_pseudo_bytes(&n, 1);
+    if (RAND_bytes(&n, 1) <= 0)
+        return -1;
     num = (n & 0x07);
 
     if (outl > num)
@@ -172,7 +170,8 @@ static int nbiof_write(BIO *b, const char *in, int inl)
         num = nt->lwn;
         nt->lwn = 0;
     } else {
-        RAND_pseudo_bytes(&n, 1);
+        if (RAND_bytes(&n, 1) <= 0)
+            return -1;
         num = (n & 7);
     }