Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
78e7b703
Commit
78e7b703
authored
Dec 13, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/ffmetadec: do no limit size of tags to 1024
Use bprint API instead. Fixes #4833.
parent
c6e1966c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
5 deletions
+52
-5
ffmetadec.c
libavformat/ffmetadec.c
+52
-5
No files found.
libavformat/ffmetadec.c
View file @
78e7b703
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#include "libavutil/bprint.h"
#include "libavutil/mathematics.h"
#include "libavutil/mathematics.h"
#include "avformat.h"
#include "avformat.h"
#include "ffmeta.h"
#include "ffmeta.h"
...
@@ -32,6 +33,48 @@ static int probe(AVProbeData *p)
...
@@ -32,6 +33,48 @@ static int probe(AVProbeData *p)
return
0
;
return
0
;
}
}
static
int64_t
read_line_to_bprint_escaped
(
AVIOContext
*
s
,
AVBPrint
*
bp
)
{
int
len
,
end
;
int64_t
read
=
0
;
char
tmp
[
1024
];
char
c
;
char
prev
=
' '
;
do
{
len
=
0
;
do
{
c
=
avio_r8
(
s
);
end
=
prev
!=
'\\'
&&
(
c
==
'\r'
||
c
==
'\n'
||
c
==
'\0'
);
if
(
!
end
)
tmp
[
len
++
]
=
c
;
prev
=
c
;
}
while
(
!
end
&&
len
<
sizeof
(
tmp
));
av_bprint_append_data
(
bp
,
tmp
,
len
);
read
+=
len
;
}
while
(
!
end
);
if
(
c
==
'\r'
&&
avio_r8
(
s
)
!=
'\n'
&&
!
avio_feof
(
s
))
avio_skip
(
s
,
-
1
);
if
(
!
c
&&
s
->
error
)
return
s
->
error
;
if
(
!
c
&&
!
read
&&
avio_feof
(
s
))
return
AVERROR_EOF
;
return
read
;
}
static
void
get_bprint_line
(
AVIOContext
*
s
,
AVBPrint
*
bp
)
{
do
{
av_bprint_clear
(
bp
);
read_line_to_bprint_escaped
(
s
,
bp
);
}
while
(
!
avio_feof
(
s
)
&&
(
bp
->
str
[
0
]
==
';'
||
bp
->
str
[
0
]
==
'#'
||
bp
->
str
[
0
]
==
0
));
}
static
void
get_line
(
AVIOContext
*
s
,
uint8_t
*
buf
,
int
size
)
static
void
get_line
(
AVIOContext
*
s
,
uint8_t
*
buf
,
int
size
)
{
{
do
{
do
{
...
@@ -128,12 +171,14 @@ static int read_tag(const uint8_t *line, AVDictionary **m)
...
@@ -128,12 +171,14 @@ static int read_tag(const uint8_t *line, AVDictionary **m)
static
int
read_header
(
AVFormatContext
*
s
)
static
int
read_header
(
AVFormatContext
*
s
)
{
{
AVDictionary
**
m
=
&
s
->
metadata
;
AVDictionary
**
m
=
&
s
->
metadata
;
uint8_t
line
[
1024
];
AVBPrint
bp
;
av_bprint_init
(
&
bp
,
0
,
AV_BPRINT_SIZE_UNLIMITED
);
while
(
!
avio_feof
(
s
->
pb
))
{
while
(
!
avio_feof
(
s
->
pb
))
{
get_
line
(
s
->
pb
,
line
,
sizeof
(
line
)
);
get_
bprint_line
(
s
->
pb
,
&
bp
);
if
(
!
memcmp
(
line
,
ID_STREAM
,
strlen
(
ID_STREAM
)))
{
if
(
!
memcmp
(
bp
.
str
,
ID_STREAM
,
strlen
(
ID_STREAM
)))
{
AVStream
*
st
=
avformat_new_stream
(
s
,
NULL
);
AVStream
*
st
=
avformat_new_stream
(
s
,
NULL
);
if
(
!
st
)
if
(
!
st
)
...
@@ -143,7 +188,7 @@ static int read_header(AVFormatContext *s)
...
@@ -143,7 +188,7 @@ static int read_header(AVFormatContext *s)
st
->
codecpar
->
codec_id
=
AV_CODEC_ID_FFMETADATA
;
st
->
codecpar
->
codec_id
=
AV_CODEC_ID_FFMETADATA
;
m
=
&
st
->
metadata
;
m
=
&
st
->
metadata
;
}
else
if
(
!
memcmp
(
line
,
ID_CHAPTER
,
strlen
(
ID_CHAPTER
)))
{
}
else
if
(
!
memcmp
(
bp
.
str
,
ID_CHAPTER
,
strlen
(
ID_CHAPTER
)))
{
AVChapter
*
ch
=
read_chapter
(
s
);
AVChapter
*
ch
=
read_chapter
(
s
);
if
(
!
ch
)
if
(
!
ch
)
...
@@ -151,9 +196,11 @@ static int read_header(AVFormatContext *s)
...
@@ -151,9 +196,11 @@ static int read_header(AVFormatContext *s)
m
=
&
ch
->
metadata
;
m
=
&
ch
->
metadata
;
}
else
}
else
read_tag
(
line
,
m
);
read_tag
(
bp
.
str
,
m
);
}
}
av_bprint_finalize
(
&
bp
,
NULL
);
s
->
start_time
=
0
;
s
->
start_time
=
0
;
if
(
s
->
nb_chapters
)
if
(
s
->
nb_chapters
)
s
->
duration
=
av_rescale_q
(
s
->
chapters
[
s
->
nb_chapters
-
1
]
->
end
,
s
->
duration
=
av_rescale_q
(
s
->
chapters
[
s
->
nb_chapters
-
1
]
->
end
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment