summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-07-12 22:28:38 +0200
committerChristian Grothoff <christian@grothoff.org>2018-07-12 22:28:38 +0200
commitf033468cd36e2b8bf92d747fbd683b2ace8da394 (patch)
tree34175544ffc736f7f678ca8449b2c25c1c30c61c
parent8fc3b15928c8c76d5edd3de88e0a173368cdc633 (diff)
fixing infinite loop, releasing 1.7
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac6
-rw-r--r--src/plugins/mpeg_extractor.c90
3 files changed, 82 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 0170cd8..dffc0ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Jul 12 22:26:36 CEST 2018
+ Fix potential infinite loop in mpeg extractor.
+ Releasing GNU libextractor 1.7. -CG
+
Thu Jul 12 21:23:43 CEST 2018
Fixing length calculation error in unzip logic reported
by ADLab of Venustech. -CG
diff --git a/configure.ac b/configure.ac
index 3fb33b0..b909572 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script.
#
# This file is part of GNU libextractor
-# Copyright (C) 2003-2017 Christian Grothoff
+# Copyright (C) 2003-2018 Christian Grothoff
#
# GNU libextractor is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
@@ -16,7 +16,7 @@
#
#
AC_PREREQ(2.61)
-AC_INIT([libextractor], [1.6], [bug-libextractor@gnu.org])
+AC_INIT([libextractor], [1.7], [bug-libextractor@gnu.org])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AH_TOP([#define _GNU_SOURCE 1])
@@ -25,7 +25,7 @@ AC_CANONICAL_HOST
AC_CANONICAL_SYSTEM
LIB_VERSION_CURRENT=4
-LIB_VERSION_REVISION=5
+LIB_VERSION_REVISION=6
LIB_VERSION_AGE=1
AC_SUBST(LIB_VERSION_CURRENT)
AC_SUBST(LIB_VERSION_REVISION)
diff --git a/src/plugins/mpeg_extractor.c b/src/plugins/mpeg_extractor.c
index c855825..627cae0 100644
--- a/src/plugins/mpeg_extractor.c
+++ b/src/plugins/mpeg_extractor.c
@@ -42,7 +42,7 @@
*
* @param ec extraction context provided to the plugin
*/
-void
+void
EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
mpeg2dec_t *handle;
@@ -51,10 +51,19 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
ssize_t avail;
mpeg2_state_t state;
char format[256];
+ char lformat[256];
char gop_format[256];
int have_gop;
uint64_t fsize;
unsigned int fail_count;
+ int did_seek;
+ int fmt1;
+ int fmt2;
+ int mime;
+ int fpal;
+ int fntsc;
+ int fsecam;
+ int fmac;
if (NULL == (handle = mpeg2_init ()))
return;
@@ -63,10 +72,19 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
mpeg2_close (handle);
return;
}
- fsize = ec->get_size (ec->cls);
+ fsize = ec->get_size (ec->cls);
buf = NULL;
have_gop = 0;
fail_count = 0;
+ did_seek = 0;
+ fmt1 = 0;
+ fmt2 = 0;
+ mime = 0;
+ fpal = 0;
+ fntsc = 0;
+ fsecam = 0;
+ fmac = 0;
+ lformat[0] = '\0';
while (1)
{
state = mpeg2_parse (handle);
@@ -86,36 +104,76 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
fail_count = 0;
format[0] = fsize;
format[0]++;
- ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
- snprintf (format,
+ if (0 == mime)
+ {
+ mime = 1;
+ ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
+ }
+ snprintf (format,
sizeof(format), "%ux%u",
info->sequence->width, info->sequence->height);
- ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
+ if (0 != strcmp (lformat,
+ format))
+ {
+ strcpy (lformat,
+ format);
+ ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
+ }
switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED)
{
case SEQ_VIDEO_FORMAT_PAL:
- ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ if (0 == fpal)
+ {
+ fpal = 1;
+ ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
break;
case SEQ_VIDEO_FORMAT_NTSC:
- ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ if (0 == fntsc)
+ {
+ fntsc = 1;
+ ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
break;
case SEQ_VIDEO_FORMAT_SECAM:
- ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ if (0 == fsecam)
+ {
+ fsecam = 1;
+ ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
break;
case SEQ_VIDEO_FORMAT_MAC:
- ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ if (0 == fmac)
+ {
+ fmac = 1;
+ ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
break;
default:
break;
}
if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
- ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION);
+ {
+ if (0 == fmt1)
+ {
+ fmt1 = 1;
+ ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION);
+ }
+ }
else
- ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION);
- if ( (fsize != -1) &&
+ {
+ if (0 == fmt2)
+ {
+ fmt2 = 1;
+ ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION);
+ }
+ }
+ if ( (0 == did_seek) &&
+ (fsize != -1) &&
(fsize > 1024 * 256 * 2) )
{
/* skip to the end of the mpeg for speed */
+ did_seek = 1;
ec->seek (ec->cls,
fsize - 256 * 1024,
SEEK_SET);
@@ -126,10 +184,12 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ( (NULL != info->gop) &&
(0 != info->gop->pictures) )
{
- snprintf (gop_format,
+ snprintf (gop_format,
sizeof (gop_format),
"%02u:%02u:%02u (%u frames)",
- info->gop->hours, info->gop->minutes, info->gop->seconds,
+ info->gop->hours,
+ info->gop->minutes,
+ info->gop->seconds,
info->gop->pictures);
have_gop = 1;
}
@@ -148,7 +208,7 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
}
EXIT:
if (1 == have_gop)
- ADD (gop_format, EXTRACTOR_METATYPE_DURATION);
+ ADD (gop_format, EXTRACTOR_METATYPE_DURATION);
mpeg2_close (handle);
}
https://gnunet.org