[FFmpeg-devel] [PATCH] lavu/opt: check int lists length for overflow.

Nicolas George nicolas.george at normalesup.org
Sat Apr 13 12:14:19 CEST 2013


Also add parens on macro arguments.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavutil/opt.h |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


Sorry, forgot to save after adding a pair of parens.


diff --git a/libavutil/opt.h b/libavutil/opt.h
index e368259..7f7b54e 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -668,8 +668,10 @@ int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int searc
  * @param flags  search flags
  */
 #define av_opt_set_int_list(obj, name, val, term, flags) \
-    av_opt_set_bin(obj, name, (const uint8_t *)val, \
-                   av_int_list_length(val, term) * sizeof(*val), flags)
+    (av_int_list_length(val, term) > INT_MAX / sizeof(*(val)) ? \
+     AVERROR(EINVAL) : \
+     av_opt_set_bin(obj, name, (const uint8_t *)(val), \
+                    av_int_list_length(val, term) * sizeof(*(val)), flags))
 /**
  * @}
  */
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list