[FFmpeg-cvslog] OpenCL: Avoid potential buffer overflow in cmdutils_opencl.c

Maneesh Gupta git at videolan.org
Tue Jun 2 00:50:16 CEST 2015


ffmpeg | branch: release/2.4 | Maneesh Gupta <maneesh.gupta at amd.com> | Tue Apr 28 13:26:31 2015 +0530| [5260ba3e16a23a2b8a0ff161cfb9a57cdf91992f] | committer: Michael Niedermayer

OpenCL: Avoid potential buffer overflow in cmdutils_opencl.c

The opt_opencl_bench function copied the device name using strcpy without checking if the source string was larger.
This patch fixes this by replacing the strcpy with av_strlcpy, with the string copy size capped to the destination buffer size.

Signed-off-by: Maneesh Gupta <maneesh.gupta at amd.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit cf234552b83a9503ff96572de2658b921b8842eb)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5260ba3e16a23a2b8a0ff161cfb9a57cdf91992f
---

 cmdutils_opencl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmdutils_opencl.c b/cmdutils_opencl.c
index 3dfd156..61478e2 100644
--- a/cmdutils_opencl.c
+++ b/cmdutils_opencl.c
@@ -22,6 +22,7 @@
 #include "libavutil/time.h"
 #include "libavutil/log.h"
 #include "libavutil/opencl.h"
+#include "libavutil/avstring.h"
 #include "cmdutils.h"
 
 typedef struct {
@@ -238,7 +239,8 @@ int opt_opencl_bench(void *optctx, const char *opt, const char *arg)
                 devices[count].platform_idx = i;
                 devices[count].device_idx = j;
                 devices[count].runtime = score;
-                strcpy(devices[count].device_name, device_node->device_name);
+                av_strlcpy(devices[count].device_name, device_node->device_name,
+                           sizeof(devices[count].device_name));
                 count++;
             }
         }



More information about the ffmpeg-cvslog mailing list