diff mbox

[FFmpeg-devel,04/10] avformat/matroskadec: Use generic size check for signed integers

Message ID 20190308092604.3752-5-andreas.rheinhardt@googlemail.com
State Accepted
Commit e5ec1318562cba507171e4af74da65d2d45764dd
Headers show

Commit Message

Andreas Rheinhardt March 8, 2019, 9:25 a.m. UTC
and drop the redundant checks contained in ebml_read_uint and
ebml_read_sint.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
---
 libavformat/matroskadec.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

James Almer March 8, 2019, 10:33 p.m. UTC | #1
On 3/8/2019 6:25 AM, Andreas Rheinhardt wrote:
> and drop the redundant checks contained in ebml_read_uint and
> ebml_read_sint.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
> ---
>  libavformat/matroskadec.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 88e80b2fda..55a153d982 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -882,9 +882,6 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
>  {
>      int n = 0;
>  
> -    if (size > 8)
> -        return AVERROR_INVALIDDATA;
> -
>      /* big-endian ordering; build up number */
>      *num = 0;
>      while (n++ < size)
> @@ -901,9 +898,6 @@ static int ebml_read_sint(AVIOContext *pb, int size, int64_t *num)
>  {
>      int n = 1;
>  
> -    if (size > 8)
> -        return AVERROR_INVALIDDATA;
> -
>      if (size == 0) {
>          *num = 0;
>      } else {
> @@ -1161,6 +1155,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
>  {
>      static const uint64_t max_lengths[EBML_TYPE_COUNT] = {
>          [EBML_UINT]  = 8,
> +        [EBML_SINT]  = 8,
>          [EBML_FLOAT] = 8,
>          // max. 16 MB for strings
>          [EBML_STR]   = 0x1000000,

Should be ok.
diff mbox

Patch

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 88e80b2fda..55a153d982 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -882,9 +882,6 @@  static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
 {
     int n = 0;
 
-    if (size > 8)
-        return AVERROR_INVALIDDATA;
-
     /* big-endian ordering; build up number */
     *num = 0;
     while (n++ < size)
@@ -901,9 +898,6 @@  static int ebml_read_sint(AVIOContext *pb, int size, int64_t *num)
 {
     int n = 1;
 
-    if (size > 8)
-        return AVERROR_INVALIDDATA;
-
     if (size == 0) {
         *num = 0;
     } else {
@@ -1161,6 +1155,7 @@  static int ebml_parse_elem(MatroskaDemuxContext *matroska,
 {
     static const uint64_t max_lengths[EBML_TYPE_COUNT] = {
         [EBML_UINT]  = 8,
+        [EBML_SINT]  = 8,
         [EBML_FLOAT] = 8,
         // max. 16 MB for strings
         [EBML_STR]   = 0x1000000,