Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
a5e8269c
Commit
a5e8269c
authored
Feb 19, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/{Aiff,Riff}: allow fstat() to fail
Omit the file size check if we don't know the size.
parent
0acc88cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
12 deletions
+25
-12
Aiff.cxx
src/tag/Aiff.cxx
+13
-6
Riff.cxx
src/tag/Riff.cxx
+12
-6
No files found.
src/tag/Aiff.cxx
View file @
a5e8269c
...
...
@@ -42,16 +42,22 @@ struct aiff_chunk_header {
uint32_t
size
;
};
gcc_pure
static
off_t
GetFileSize
(
FILE
*
file
)
{
struct
stat
st
;
return
fstat
(
fileno
(
file
),
&
st
)
==
0
?
st
.
st_size
:
-
1
;
}
size_t
aiff_seek_id3
(
FILE
*
file
)
{
/* determine the file size */
struct
stat
st
;
if
(
fstat
(
fileno
(
file
),
&
st
)
<
0
)
{
LogErrno
(
aiff_domain
,
"Failed to stat file descriptor"
);
return
0
;
}
const
off_t
file_size
=
GetFileSize
(
file
);
/* seek to the beginning and read the AIFF header */
...
...
@@ -64,7 +70,8 @@ aiff_seek_id3(FILE *file)
size_t
size
=
fread
(
&
header
,
sizeof
(
header
),
1
,
file
);
if
(
size
!=
1
||
memcmp
(
header
.
id
,
"FORM"
,
4
)
!=
0
||
FromBE32
(
header
.
size
)
>
(
uint32_t
)
st
.
st_size
||
(
file_size
>=
0
&&
FromBE32
(
header
.
size
)
>
(
uint32_t
)
file_size
)
||
(
memcmp
(
header
.
format
,
"AIFF"
,
4
)
!=
0
&&
memcmp
(
header
.
format
,
"AIFC"
,
4
)
!=
0
))
/* not a AIFF file */
...
...
src/tag/Riff.cxx
View file @
a5e8269c
...
...
@@ -42,16 +42,22 @@ struct riff_chunk_header {
uint32_t
size
;
};
gcc_pure
static
off_t
GetFileSize
(
FILE
*
file
)
{
struct
stat
st
;
return
fstat
(
fileno
(
file
),
&
st
)
==
0
?
st
.
st_size
:
-
1
;
}
size_t
riff_seek_id3
(
FILE
*
file
)
{
/* determine the file size */
struct
stat
st
;
if
(
fstat
(
fileno
(
file
),
&
st
)
<
0
)
{
LogErrno
(
riff_domain
,
"Failed to stat file descriptor"
);
return
0
;
}
const
off_t
file_size
=
GetFileSize
(
file
);
/* seek to the beginning and read the RIFF header */
...
...
@@ -64,7 +70,7 @@ riff_seek_id3(FILE *file)
size_t
size
=
fread
(
&
header
,
sizeof
(
header
),
1
,
file
);
if
(
size
!=
1
||
memcmp
(
header
.
id
,
"RIFF"
,
4
)
!=
0
||
FromLE32
(
header
.
size
)
>
(
uint32_t
)
st
.
st_size
)
(
file_size
>=
0
&&
FromLE32
(
header
.
size
)
>
(
uint32_t
)
file_size
)
)
/* not a RIFF file */
return
0
;
...
...
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