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

index b07e31252b9b39971f126f05f254db4a127c952d..90de68c851a49259b4042949c15abd7955715901 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);