ossl.c: integer overflow
* ext/openssl/ossl.c (string2hex): fix signed integer overflow. [ruby-core:51711] [Bug #7744] [Fixes GH-242] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b06f4a9398
commit
3e37a7f745
@ -18,11 +18,12 @@ int
|
|||||||
string2hex(const unsigned char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
|
string2hex(const unsigned char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
|
||||||
{
|
{
|
||||||
static const char hex[]="0123456789abcdef";
|
static const char hex[]="0123456789abcdef";
|
||||||
int i, len = 2 * buf_len;
|
int i, len;
|
||||||
|
|
||||||
if (buf_len < 0 || len < buf_len) { /* PARANOIA? */
|
if (buf_len < 0 || buf_len > INT_MAX / 2) { /* PARANOIA? */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
len = 2 * buf_len;
|
||||||
if (!hexbuf) { /* if no buf, return calculated len */
|
if (!hexbuf) { /* if no buf, return calculated len */
|
||||||
if (hexbuf_len) {
|
if (hexbuf_len) {
|
||||||
*hexbuf_len = len;
|
*hexbuf_len = len;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user