diff mbox

[FFmpeg-devel] lavfi/zmq: Avoid mem copy past the end of input buffer

Message ID 20190730211608.24467-1-andriy.gelman@gmail.com
State Accepted
Commit f60b1211b2aa7b6e8902d64072b678b4ccd87e54
Headers show

Commit Message

Andriy Gelman July 30, 2019, 9:16 p.m. UTC
From: Andriy Gelman <andriy.gelman@gmail.com>

---
 libavfilter/f_zmq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul B Mahol Aug. 1, 2019, 3:36 p.m. UTC | #1
On Tue, Jul 30, 2019 at 11:24 PM Andriy Gelman <andriy.gelman@gmail.com>
wrote:

> From: Andriy Gelman <andriy.gelman@gmail.com>
>
> ---
>  libavfilter/f_zmq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
> index 89da5bef06..744c721305 100644
> --- a/libavfilter/f_zmq.c
> +++ b/libavfilter/f_zmq.c
> @@ -139,7 +139,7 @@ static int recv_msg(AVFilterContext *ctx, char **buf,
> int *buf_size)
>          ret = AVERROR(ENOMEM);
>          goto end;
>      }
> -    memcpy(*buf, zmq_msg_data(&msg), *buf_size);
> +    memcpy(*buf, zmq_msg_data(&msg), *buf_size - 1);
>      (*buf)[*buf_size-1] = 0;
>
>  end:
> --
> 2.22.0
>

LGTM, I can not apply it, so I kindly ask other committers to apply it.
Carl Eugen Hoyos Aug. 1, 2019, 5:10 p.m. UTC | #2
Am Di., 30. Juli 2019 um 23:25 Uhr schrieb Andriy Gelman
<andriy.gelman@gmail.com>:
>
> From: Andriy Gelman <andriy.gelman@gmail.com>
>
> ---
>  libavfilter/f_zmq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
> index 89da5bef06..744c721305 100644
> --- a/libavfilter/f_zmq.c
> +++ b/libavfilter/f_zmq.c
> @@ -139,7 +139,7 @@ static int recv_msg(AVFilterContext *ctx, char **buf, int *buf_size)
>          ret = AVERROR(ENOMEM);
>          goto end;
>      }
> -    memcpy(*buf, zmq_msg_data(&msg), *buf_size);
> +    memcpy(*buf, zmq_msg_data(&msg), *buf_size - 1);

Patch applied.

Carl Eugen
diff mbox

Patch

diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
index 89da5bef06..744c721305 100644
--- a/libavfilter/f_zmq.c
+++ b/libavfilter/f_zmq.c
@@ -139,7 +139,7 @@  static int recv_msg(AVFilterContext *ctx, char **buf, int *buf_size)
         ret = AVERROR(ENOMEM);
         goto end;
     }
-    memcpy(*buf, zmq_msg_data(&msg), *buf_size);
+    memcpy(*buf, zmq_msg_data(&msg), *buf_size - 1);
     (*buf)[*buf_size-1] = 0;
 
 end: