提交 dc9887c0 编写于 作者: K Kurt Roeckx

Avoid creating an illegal pointer

Found by tis-interpreter
Reviewed-by: NRich Salz <rsalz@openssl.org>

GH: #1122
上级 223516ea
...@@ -201,18 +201,18 @@ static size_t c2i_ibuf(unsigned char *b, int *pneg, ...@@ -201,18 +201,18 @@ static size_t c2i_ibuf(unsigned char *b, int *pneg,
/* Must be negative: calculate twos complement */ /* Must be negative: calculate twos complement */
if (b) { if (b) {
const unsigned char *from = p + plen - 1 + pad; const unsigned char *from = p + plen - 1 + pad;
unsigned char *to = b + plen - 1; unsigned char *to = b + plen;
i = plen; i = plen;
while (*from == 0 && i) { while (*from == 0 && i) {
*to-- = 0; *--to = 0;
i--; i--;
from--; from--;
} }
*to-- = (*from-- ^ 0xff) + 1; *--to = (*from-- ^ 0xff) + 1;
OPENSSL_assert(i != 0); OPENSSL_assert(i != 0);
i--; i--;
for (; i > 0; i--) for (; i > 0; i--)
*to-- = *from-- ^ 0xff; *--to = *from-- ^ 0xff;
} }
return plen; return plen;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册