check buffer is larger enough before overwriting

This commit is contained in:
Dr. Stephen Henson 2011-04-06 18:06:54 +00:00
parent 2ab42de1ec
commit f2c358c6ce

View 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);