nut: Provide more information on failure
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 24 Nov 2015 00:24:47 +0000 (01:24 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Wed, 25 Nov 2015 08:01:25 +0000 (09:01 +0100)
libavformat/nutdec.c

index bf1ab7b..e560a7e 100644 (file)
@@ -238,7 +238,9 @@ static int decode_main_header(NUTContext *nut)
         GET_V(nut->time_base[i].num, tmp > 0 && tmp < (1ULL << 31));
         GET_V(nut->time_base[i].den, tmp > 0 && tmp < (1ULL << 31));
         if (av_gcd(nut->time_base[i].num, nut->time_base[i].den) != 1) {
-            av_log(s, AV_LOG_ERROR, "time base invalid\n");
+            av_log(s, AV_LOG_ERROR, "invalid time base %d/%d\n",
+                   nut->time_base[i].num,
+                   nut->time_base[i].den);
             return AVERROR_INVALIDDATA;
         }
     }
@@ -281,7 +283,8 @@ static int decode_main_header(NUTContext *nut)
             return AVERROR_INVALIDDATA;
         }
         if (tmp_stream >= stream_count) {
-            av_log(s, AV_LOG_ERROR, "illegal stream number\n");
+            av_log(s, AV_LOG_ERROR, "illegal stream number %d >= %d\n",
+                   tmp_stream, stream_count);
             return AVERROR_INVALIDDATA;
         }
 
@@ -309,11 +312,13 @@ static int decode_main_header(NUTContext *nut)
         for (i = 1; i < nut->header_count; i++) {
             uint8_t *hdr;
             GET_V(nut->header_len[i], tmp > 0 && tmp < 256);
-            rem -= nut->header_len[i];
-            if (rem < 0) {
-                av_log(s, AV_LOG_ERROR, "invalid elision header\n");
+            if (rem < nut->header_len[i]) {
+                av_log(s, AV_LOG_ERROR,
+                       "invalid elision header %d : %d > %d\n",
+                       i, nut->header_len[i], rem);
                 return AVERROR_INVALIDDATA;
             }
+            rem -= nut->header_len[i];
             hdr = av_malloc(nut->header_len[i]);
             if (!hdr)
                 return AVERROR(ENOMEM);