提交 3fde6c92 编写于 作者: M Matt Caswell

Avoid undefined behaviour in PACKET_buf_init

Change the sanity check in PACKET_buf_init to check for excessive length
buffers, which should catch the interesting cases where len has been cast
from a negative value whilst avoiding any undefined behaviour.

RT#4094
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 788d72ba
......@@ -111,7 +111,7 @@ __owur static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf,
size_t len)
{
/* Sanity check for negative values. */
if (buf + len < buf)
if (len > (size_t)(SIZE_MAX / 2))
return 0;
pkt->curr = buf;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册