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

index d524534..7590f6f 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);