提交 90e965be 编写于 作者: A Andriy Gelman 提交者: Michael Niedermayer

tools/zmqsend: Avoid mem copy past the end of input buffer

This patch avoids a read past the end of the input buffer in memcpy since the size
of the received zmq message is recv_buf_size - 1.
Reviewed-by: NPaul B Mahol <onemda@gmail.com>
Signed-off-by: NMichael Niedermayer <michael@niedermayer.cc>
上级 86d13e95
......@@ -155,7 +155,7 @@ int main(int argc, char **argv)
ret = 1;
goto end;
}
memcpy(recv_buf, zmq_msg_data(&msg), recv_buf_size);
memcpy(recv_buf, zmq_msg_data(&msg), recv_buf_size - 1);
recv_buf[recv_buf_size-1] = 0;
printf("%s\n", recv_buf);
zmq_msg_close(&msg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册