Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
flac
Commits
5b4c4896
Commit
5b4c4896
authored
Oct 31, 2001
by
Josh Coalson
Browse files
fix bugs with skipping id3v2 tags and long metadata blocks
parent
89c899ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/metaflac/main.c
View file @
5b4c4896
...
...
@@ -138,8 +138,45 @@ FLAC__bool list(FILE *f, FLAC__bool verbose)
FLAC__StreamMetaData
metadata
;
unsigned
blocknum
=
0
,
byte_offset
=
0
,
i
;
/* read the stream sync code */
if
(
fread
(
buf
,
1
,
4
,
f
)
<
4
||
memcmp
(
buf
,
sync_string_
,
4
))
{
/* skip any id3v2 tag */
if
(
fread
(
buf
,
1
,
4
,
f
)
<
4
)
{
fprintf
(
stderr
,
"ERROR: not a FLAC file
\n
"
);
return
false
;
}
if
(
0
==
memcmp
(
buf
,
"ID3"
,
3
))
{
unsigned
tag_length
=
0
;
/* skip to the tag length */
if
(
fseek
(
f
,
2
,
SEEK_CUR
)
<
0
)
{
fprintf
(
stderr
,
"ERROR: bad ID3v2 tag
\n
"
);
return
false
;
}
/* read the length */
for
(
i
=
0
;
i
<
4
;
i
++
)
{
if
(
fread
(
buf
,
1
,
1
,
f
)
<
1
||
buf
[
0
]
&
0x80
)
{
fprintf
(
stderr
,
"ERROR: bad ID3v2 tag
\n
"
);
return
false
;
}
tag_length
<<=
7
;
tag_length
|=
(
buf
[
0
]
&
0x7f
);
}
/* skip the rest of the tag */
if
(
fseek
(
f
,
tag_length
,
SEEK_CUR
)
<
0
)
{
fprintf
(
stderr
,
"ERROR: bad ID3v2 tag
\n
"
);
return
false
;
}
/* read the stream sync code */
if
(
fread
(
buf
,
1
,
4
,
f
)
<
4
)
{
fprintf
(
stderr
,
"ERROR: not a FLAC file (no '%s' header)
\n
"
,
sync_string_
);
return
false
;
}
}
/* check the stream sync code */
if
(
memcmp
(
buf
,
sync_string_
,
4
))
{
fprintf
(
stderr
,
"ERROR: not a FLAC file (no '%s' header)
\n
"
,
sync_string_
);
return
false
;
}
...
...
@@ -165,6 +202,10 @@ FLAC__bool list(FILE *f, FLAC__bool verbose)
if
(
metadata
.
length
>
sizeof
(
buf
))
{
printf
(
" SKIPPING large block
\n
"
);
if
(
fseek
(
f
,
metadata
.
length
,
SEEK_CUR
)
<
0
)
{
fprintf
(
stderr
,
"ERROR: short count skipping metadata block data
\n
"
);
return
false
;
}
continue
;
}
...
...
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