Commit 90e965be authored by Andriy Gelman's avatar Andriy Gelman Committed by 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: 's avatarPaul B Mahol <onemda@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 86d13e95
...@@ -155,7 +155,7 @@ int main(int argc, char **argv) ...@@ -155,7 +155,7 @@ int main(int argc, char **argv)
ret = 1; ret = 1;
goto end; 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; recv_buf[recv_buf_size-1] = 0;
printf("%s\n", recv_buf); printf("%s\n", recv_buf);
zmq_msg_close(&msg); zmq_msg_close(&msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment