aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManeesh Gupta <maneesh.gupta@amd.com>2015-04-28 13:08:31 +0530
committerMichael Niedermayer <michaelni@gmx.at>2015-05-15 10:04:50 +0200
commit86a360e34985e881dec58ee2b4af0600e43bfc79 (patch)
tree0949e2cb600b2c681cdd4c036ca771e182cb5216
parent07ad029d1b95f7f37bd8f03a0514e34098573efb (diff)
downloadffmpeg-86a360e34985e881dec58ee2b4af0600e43bfc79.tar.gz
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@amd.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit cf234552b83a9503ff96572de2658b921b8842eb) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--cmdutils_opencl.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/cmdutils_opencl.c b/cmdutils_opencl.c
index 3dfd156195..61478e27af 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++;
}
}