diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-07-12 22:28:38 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-07-12 22:28:38 +0200 |
commit | f033468cd36e2b8bf92d747fbd683b2ace8da394 (patch) | |
tree | 34175544ffc736f7f678ca8449b2c25c1c30c61c | |
parent | 8fc3b15928c8c76d5edd3de88e0a173368cdc633 (diff) | |
download | libextractor-f033468cd36e2b8bf92d747fbd683b2ace8da394.tar.gz libextractor-f033468cd36e2b8bf92d747fbd683b2ace8da394.zip |
fixing infinite loop, releasing 1.7
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/plugins/mpeg_extractor.c | 90 |
3 files changed, 82 insertions, 18 deletions
@@ -1,3 +1,7 @@ | |||
1 | Thu Jul 12 22:26:36 CEST 2018 | ||
2 | Fix potential infinite loop in mpeg extractor. | ||
3 | Releasing GNU libextractor 1.7. -CG | ||
4 | |||
1 | Thu Jul 12 21:23:43 CEST 2018 | 5 | Thu Jul 12 21:23:43 CEST 2018 |
2 | Fixing length calculation error in unzip logic reported | 6 | Fixing length calculation error in unzip logic reported |
3 | by ADLab of Venustech. -CG | 7 | 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 @@ | |||
1 | # Process this file with autoconf to produce a configure script. | 1 | # Process this file with autoconf to produce a configure script. |
2 | # | 2 | # |
3 | # This file is part of GNU libextractor | 3 | # This file is part of GNU libextractor |
4 | # Copyright (C) 2003-2017 Christian Grothoff | 4 | # Copyright (C) 2003-2018 Christian Grothoff |
5 | # | 5 | # |
6 | # GNU libextractor is free software; you can redistribute it and/or modify it under the | 6 | # GNU libextractor is free software; you can redistribute it and/or modify it under the |
7 | # terms of the GNU General Public License as published by the Free Software | 7 | # terms of the GNU General Public License as published by the Free Software |
@@ -16,7 +16,7 @@ | |||
16 | # | 16 | # |
17 | # | 17 | # |
18 | AC_PREREQ(2.61) | 18 | AC_PREREQ(2.61) |
19 | AC_INIT([libextractor], [1.6], [bug-libextractor@gnu.org]) | 19 | AC_INIT([libextractor], [1.7], [bug-libextractor@gnu.org]) |
20 | AC_CONFIG_HEADERS([config.h]) | 20 | AC_CONFIG_HEADERS([config.h]) |
21 | AC_CONFIG_MACRO_DIR([m4]) | 21 | AC_CONFIG_MACRO_DIR([m4]) |
22 | AH_TOP([#define _GNU_SOURCE 1]) | 22 | AH_TOP([#define _GNU_SOURCE 1]) |
@@ -25,7 +25,7 @@ AC_CANONICAL_HOST | |||
25 | AC_CANONICAL_SYSTEM | 25 | AC_CANONICAL_SYSTEM |
26 | 26 | ||
27 | LIB_VERSION_CURRENT=4 | 27 | LIB_VERSION_CURRENT=4 |
28 | LIB_VERSION_REVISION=5 | 28 | LIB_VERSION_REVISION=6 |
29 | LIB_VERSION_AGE=1 | 29 | LIB_VERSION_AGE=1 |
30 | AC_SUBST(LIB_VERSION_CURRENT) | 30 | AC_SUBST(LIB_VERSION_CURRENT) |
31 | AC_SUBST(LIB_VERSION_REVISION) | 31 | 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 @@ | |||
42 | * | 42 | * |
43 | * @param ec extraction context provided to the plugin | 43 | * @param ec extraction context provided to the plugin |
44 | */ | 44 | */ |
45 | void | 45 | void |
46 | EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | 46 | EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) |
47 | { | 47 | { |
48 | mpeg2dec_t *handle; | 48 | mpeg2dec_t *handle; |
@@ -51,10 +51,19 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
51 | ssize_t avail; | 51 | ssize_t avail; |
52 | mpeg2_state_t state; | 52 | mpeg2_state_t state; |
53 | char format[256]; | 53 | char format[256]; |
54 | char lformat[256]; | ||
54 | char gop_format[256]; | 55 | char gop_format[256]; |
55 | int have_gop; | 56 | int have_gop; |
56 | uint64_t fsize; | 57 | uint64_t fsize; |
57 | unsigned int fail_count; | 58 | unsigned int fail_count; |
59 | int did_seek; | ||
60 | int fmt1; | ||
61 | int fmt2; | ||
62 | int mime; | ||
63 | int fpal; | ||
64 | int fntsc; | ||
65 | int fsecam; | ||
66 | int fmac; | ||
58 | 67 | ||
59 | if (NULL == (handle = mpeg2_init ())) | 68 | if (NULL == (handle = mpeg2_init ())) |
60 | return; | 69 | return; |
@@ -63,10 +72,19 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
63 | mpeg2_close (handle); | 72 | mpeg2_close (handle); |
64 | return; | 73 | return; |
65 | } | 74 | } |
66 | fsize = ec->get_size (ec->cls); | 75 | fsize = ec->get_size (ec->cls); |
67 | buf = NULL; | 76 | buf = NULL; |
68 | have_gop = 0; | 77 | have_gop = 0; |
69 | fail_count = 0; | 78 | fail_count = 0; |
79 | did_seek = 0; | ||
80 | fmt1 = 0; | ||
81 | fmt2 = 0; | ||
82 | mime = 0; | ||
83 | fpal = 0; | ||
84 | fntsc = 0; | ||
85 | fsecam = 0; | ||
86 | fmac = 0; | ||
87 | lformat[0] = '\0'; | ||
70 | while (1) | 88 | while (1) |
71 | { | 89 | { |
72 | state = mpeg2_parse (handle); | 90 | state = mpeg2_parse (handle); |
@@ -86,36 +104,76 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
86 | fail_count = 0; | 104 | fail_count = 0; |
87 | format[0] = fsize; | 105 | format[0] = fsize; |
88 | format[0]++; | 106 | format[0]++; |
89 | ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE); | 107 | if (0 == mime) |
90 | snprintf (format, | 108 | { |
109 | mime = 1; | ||
110 | ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE); | ||
111 | } | ||
112 | snprintf (format, | ||
91 | sizeof(format), "%ux%u", | 113 | sizeof(format), "%ux%u", |
92 | info->sequence->width, info->sequence->height); | 114 | info->sequence->width, info->sequence->height); |
93 | ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); | 115 | if (0 != strcmp (lformat, |
116 | format)) | ||
117 | { | ||
118 | strcpy (lformat, | ||
119 | format); | ||
120 | ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); | ||
121 | } | ||
94 | switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED) | 122 | switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED) |
95 | { | 123 | { |
96 | case SEQ_VIDEO_FORMAT_PAL: | 124 | case SEQ_VIDEO_FORMAT_PAL: |
97 | ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 125 | if (0 == fpal) |
126 | { | ||
127 | fpal = 1; | ||
128 | ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | ||
129 | } | ||
98 | break; | 130 | break; |
99 | case SEQ_VIDEO_FORMAT_NTSC: | 131 | case SEQ_VIDEO_FORMAT_NTSC: |
100 | ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 132 | if (0 == fntsc) |
133 | { | ||
134 | fntsc = 1; | ||
135 | ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | ||
136 | } | ||
101 | break; | 137 | break; |
102 | case SEQ_VIDEO_FORMAT_SECAM: | 138 | case SEQ_VIDEO_FORMAT_SECAM: |
103 | ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 139 | if (0 == fsecam) |
140 | { | ||
141 | fsecam = 1; | ||
142 | ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | ||
143 | } | ||
104 | break; | 144 | break; |
105 | case SEQ_VIDEO_FORMAT_MAC: | 145 | case SEQ_VIDEO_FORMAT_MAC: |
106 | ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 146 | if (0 == fmac) |
147 | { | ||
148 | fmac = 1; | ||
149 | ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | ||
150 | } | ||
107 | break; | 151 | break; |
108 | default: | 152 | default: |
109 | break; | 153 | break; |
110 | } | 154 | } |
111 | if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0) | 155 | if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0) |
112 | ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION); | 156 | { |
157 | if (0 == fmt1) | ||
158 | { | ||
159 | fmt1 = 1; | ||
160 | ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION); | ||
161 | } | ||
162 | } | ||
113 | else | 163 | else |
114 | ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION); | 164 | { |
115 | if ( (fsize != -1) && | 165 | if (0 == fmt2) |
166 | { | ||
167 | fmt2 = 1; | ||
168 | ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION); | ||
169 | } | ||
170 | } | ||
171 | if ( (0 == did_seek) && | ||
172 | (fsize != -1) && | ||
116 | (fsize > 1024 * 256 * 2) ) | 173 | (fsize > 1024 * 256 * 2) ) |
117 | { | 174 | { |
118 | /* skip to the end of the mpeg for speed */ | 175 | /* skip to the end of the mpeg for speed */ |
176 | did_seek = 1; | ||
119 | ec->seek (ec->cls, | 177 | ec->seek (ec->cls, |
120 | fsize - 256 * 1024, | 178 | fsize - 256 * 1024, |
121 | SEEK_SET); | 179 | SEEK_SET); |
@@ -126,10 +184,12 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
126 | if ( (NULL != info->gop) && | 184 | if ( (NULL != info->gop) && |
127 | (0 != info->gop->pictures) ) | 185 | (0 != info->gop->pictures) ) |
128 | { | 186 | { |
129 | snprintf (gop_format, | 187 | snprintf (gop_format, |
130 | sizeof (gop_format), | 188 | sizeof (gop_format), |
131 | "%02u:%02u:%02u (%u frames)", | 189 | "%02u:%02u:%02u (%u frames)", |
132 | info->gop->hours, info->gop->minutes, info->gop->seconds, | 190 | info->gop->hours, |
191 | info->gop->minutes, | ||
192 | info->gop->seconds, | ||
133 | info->gop->pictures); | 193 | info->gop->pictures); |
134 | have_gop = 1; | 194 | have_gop = 1; |
135 | } | 195 | } |
@@ -148,7 +208,7 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
148 | } | 208 | } |
149 | EXIT: | 209 | EXIT: |
150 | if (1 == have_gop) | 210 | if (1 == have_gop) |
151 | ADD (gop_format, EXTRACTOR_METATYPE_DURATION); | 211 | ADD (gop_format, EXTRACTOR_METATYPE_DURATION); |
152 | mpeg2_close (handle); | 212 | mpeg2_close (handle); |
153 | } | 213 | } |
154 | 214 | ||