check buffer is larger enough before overwriting
authorDr. Stephen Henson <steve@openssl.org>
Wed, 6 Apr 2011 18:07:02 +0000 (18:07 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 6 Apr 2011 18:07:02 +0000 (18:07 +0000)
crypto/ecdsa/ecdsatest.c

index aa4e1481a8f3439427bb237982c72e6e4db533f5..26a4a9ee7c977c86658e2fdc006e3cec40f5a755 100644 (file)
@@ -168,10 +168,9 @@ int fbytes(unsigned char *buf, int num)
                return 0;
                }
        fbytes_counter ++;
-       ret = BN_bn2bin(tmp, buf);      
-       if (ret == 0 || ret != num)
+       if (num != BN_num_bytes(tmp) || !BN_bn2bin(tmp, buf))
                ret = 0;
-       else
+       else 
                ret = 1;
        if (tmp)
                BN_free(tmp);