Seek out and destroy another evil cast.
[openssl.git] / crypto / rsa / rsa_pk1.c
index f0ae51f234ebf9650d51a4a3fc9e322cba88bb2e..b35eb626824e2f7dc49af7e3a3e4e61698e23340 100644 (file)
@@ -155,12 +155,14 @@ int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
        /* pad out with non-zero random data */
        j=tlen-3-flen;
 
-       RAND_bytes(p,j);
+       if (RAND_bytes(p,j) <= 0)
+               return(0);
        for (i=0; i<j; i++)
                {
                if (*p == '\0')
                        do      {
-                               RAND_bytes(p,1);
+                               if (RAND_bytes(p,1) <= 0)
+                                       return(0);
                                } while (*p == '\0');
                p++;
                }