[FFmpeg-cvslog] parseutils: fix parsing of invalid alpha values

Mans Rullgard git at videolan.org
Sun Oct 7 11:43:25 CEST 2012


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Sat Oct  6 10:21:22 2012 +0100| [6221e2478c593a0ce1183eed929cb2101dbf5265] | committer: Mans Rullgard

parseutils: fix parsing of invalid alpha values

An alpha specifier outside the valid range results in a conversion from
double to long with undefined result.  Range-checking the double and
only converting it after it passes avoids this.

Fixes fate-parseutils errors on some systems.

Signed-off-by: Mans Rullgard <mans at mansr.com>

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

 libavutil/parseutils.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 0ca179e..d3f08b7 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -355,7 +355,7 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
     }
 
     if (tail) {
-        unsigned long int alpha;
+        double alpha;
         const char *alpha_string = tail;
         if (!strncmp(alpha_string, "0x", 2)) {
             alpha = strtoul(alpha_string, &tail, 16);
@@ -363,7 +363,7 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
             alpha = 255 * strtod(alpha_string, &tail);
         }
 
-        if (tail == alpha_string || *tail || alpha > 255) {
+        if (tail == alpha_string || *tail || alpha > 255 || alpha < 0) {
             av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n",
                    alpha_string, color_string);
             return AVERROR(EINVAL);



More information about the ffmpeg-cvslog mailing list