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
53f728a0
Commit
53f728a0
authored
Mar 27, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just to be carfile, make sure to null terminate when using strncpy
git-svn-id:
https://svn.musicpd.org/mpd/trunk@506
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
12d19ccc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
decode.c
src/decode.c
+8
-0
main.c
src/main.c
+6
-2
player.c
src/player.c
+5
-0
No files found.
src/decode.c
View file @
53f728a0
...
@@ -116,6 +116,7 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
...
@@ -116,6 +116,7 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
if
(
dc
->
start
||
dc
->
error
!=
DECODE_ERROR_NOERROR
)
{
if
(
dc
->
start
||
dc
->
error
!=
DECODE_ERROR_NOERROR
)
{
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
pc
->
erroredFile
[
MAXPATHLEN
]
=
'\0'
;
pc
->
error
=
PLAYER_ERROR_FILE
;
pc
->
error
=
PLAYER_ERROR_FILE
;
quitDecode
(
pc
,
dc
);
quitDecode
(
pc
,
dc
);
return
-
1
;
return
-
1
;
...
@@ -123,6 +124,7 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
...
@@ -123,6 +124,7 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
if
(
initAudio
(
af
)
<
0
)
{
if
(
initAudio
(
af
)
<
0
)
{
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
pc
->
erroredFile
[
MAXPATHLEN
]
=
'\0'
;
pc
->
error
=
PLAYER_ERROR_AUDIO
;
pc
->
error
=
PLAYER_ERROR_AUDIO
;
quitDecode
(
pc
,
dc
);
quitDecode
(
pc
,
dc
);
return
-
1
;
return
-
1
;
...
@@ -184,6 +186,7 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
...
@@ -184,6 +186,7 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
else { \
else { \
if(initAudio(NULL)<0) { \
if(initAudio(NULL)<0) { \
strncpy(pc->erroredFile,pc->file,MAXPATHLEN); \
strncpy(pc->erroredFile,pc->file,MAXPATHLEN); \
pc->erroredFile[MAXPATHLEN] = '\0' \
pc->error = PLAYER_ERROR_AUDIO; \
pc->error = PLAYER_ERROR_AUDIO; \
quitDecode(pc,dc); \
quitDecode(pc,dc); \
return; \
return; \
...
@@ -221,6 +224,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
...
@@ -221,6 +224,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
while
(
1
)
{
while
(
1
)
{
if
(
dc
->
start
)
{
if
(
dc
->
start
)
{
strncpy
(
dc
->
file
,
pc
->
file
,
MAXPATHLEN
);
strncpy
(
dc
->
file
,
pc
->
file
,
MAXPATHLEN
);
dc
->
file
[
MAXPATHLEN
]
=
'\0'
;
switch
(
pc
->
decodeType
)
{
switch
(
pc
->
decodeType
)
{
#ifdef HAVE_MAD
#ifdef HAVE_MAD
case
DECODE_TYPE_MP3
:
case
DECODE_TYPE_MP3
:
...
@@ -252,6 +256,9 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
...
@@ -252,6 +256,9 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
#endif
#endif
default:
default:
ret
=
DECODE_ERROR_UNKTYPE
;
ret
=
DECODE_ERROR_UNKTYPE
;
strncpy
(
pc
->
erroredFile
,
dc
->
file
,
MAXPATHLEN
);
pc
->
erroredFile
[
MAXPATHLEN
]
=
'\0'
;
}
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
dc
->
error
=
DECODE_ERROR_FILE
;
dc
->
error
=
DECODE_ERROR_FILE
;
...
@@ -273,6 +280,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
...
@@ -273,6 +280,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
}
}
else
if
(
pid
<
0
)
{
else
if
(
pid
<
0
)
{
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
pc
->
erroredFile
[
MAXPATHLEN
]
=
'\0'
;
pc
->
error
=
PLAYER_ERROR_SYSTEM
;
pc
->
error
=
PLAYER_ERROR_SYSTEM
;
return
-
1
;
return
-
1
;
}
}
...
...
src/main.c
View file @
53f728a0
...
@@ -331,11 +331,15 @@ int main(int argc, char * argv[]) {
...
@@ -331,11 +331,15 @@ int main(int argc, char * argv[]) {
initTables
();
initTables
();
initPlaylist
();
initPlaylist
();
if
(
!
options
.
dbFile
)
{
if
(
!
options
.
dbFile
)
{
strncpy
(
directorydb
,
playlistDir
,
MAXPATHLEN
);
strncpy
(
directorydb
,
playlistDir
,
MAXPATHLEN
);
directorydb
[
MAXPATHLEN
]
=
'\0'
;
strncat
(
directorydb
,
"/.mpddb"
,
MAXPATHLEN
-
strlen
(
playlistDir
));
strncat
(
directorydb
,
"/.mpddb"
,
MAXPATHLEN
-
strlen
(
playlistDir
));
}
}
else
strncpy
(
directorydb
,
options
.
dbFile
,
MAXPATHLEN
);
else
{
strncpy
(
directorydb
,
options
.
dbFile
,
MAXPATHLEN
);
directorydb
[
MAXPATHLEN
]
=
'\0'
;
}
if
(
options
.
createDB
>
0
||
readDirectoryDB
()
<
0
)
{
if
(
options
.
createDB
>
0
||
readDirectoryDB
()
<
0
)
{
if
(
options
.
createDB
<
0
)
{
if
(
options
.
createDB
<
0
)
{
ERROR
(
"can't open db file and using
\"
--no-create-db
\"
"
ERROR
(
"can't open db file and using
\"
--no-create-db
\"
"
...
...
src/player.c
View file @
53f728a0
...
@@ -182,6 +182,7 @@ int playerPlay(FILE * fp, char * utf8file) {
...
@@ -182,6 +182,7 @@ int playerPlay(FILE * fp, char * utf8file) {
struct
stat
st
;
struct
stat
st
;
if
(
stat
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
&
st
)
<
0
)
{
if
(
stat
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
&
st
)
<
0
)
{
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
pc
->
erroredFile
[
MAXPATHLEN
]
=
'\0'
;
pc
->
error
=
PLAYER_ERROR_FILENOTFOUND
;
pc
->
error
=
PLAYER_ERROR_FILENOTFOUND
;
return
0
;
return
0
;
}
}
...
@@ -190,12 +191,14 @@ int playerPlay(FILE * fp, char * utf8file) {
...
@@ -190,12 +191,14 @@ int playerPlay(FILE * fp, char * utf8file) {
decodeType
=
playerGetDecodeType
(
utf8file
);
decodeType
=
playerGetDecodeType
(
utf8file
);
if
(
decodeType
<
0
)
{
if
(
decodeType
<
0
)
{
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
pc
->
erroredFile
[
MAXPATHLEN
]
=
'\0'
;
pc
->
error
=
PLAYER_ERROR_UNKTYPE
;
pc
->
error
=
PLAYER_ERROR_UNKTYPE
;
return
0
;
return
0
;
}
}
pc
->
decodeType
=
decodeType
;
pc
->
decodeType
=
decodeType
;
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
pc
->
file
[
MAXPATHLEN
]
=
'\0'
;
pc
->
play
=
1
;
pc
->
play
=
1
;
if
(
player_pid
==
0
&&
playerInit
()
<
0
)
{
if
(
player_pid
==
0
&&
playerInit
()
<
0
)
{
...
@@ -327,6 +330,7 @@ int queueSong(char * utf8file) {
...
@@ -327,6 +330,7 @@ int queueSong(char * utf8file) {
if
(
pc
->
queueState
==
PLAYER_QUEUE_BLANK
)
{
if
(
pc
->
queueState
==
PLAYER_QUEUE_BLANK
)
{
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
pc
->
file
[
MAXPATHLEN
]
=
'\0'
;
decodeType
=
playerGetDecodeType
(
utf8file
);
decodeType
=
playerGetDecodeType
(
utf8file
);
if
(
decodeType
<
0
)
return
-
1
;
if
(
decodeType
<
0
)
return
-
1
;
...
@@ -393,6 +397,7 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
...
@@ -393,6 +397,7 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
pc
->
decodeType
=
decodeType
;
pc
->
decodeType
=
decodeType
;
strncpy
(
pc
->
file
,
file
,
MAXPATHLEN
);
strncpy
(
pc
->
file
,
file
,
MAXPATHLEN
);
pc
->
file
[
MAXPATHLEN
]
=
'\0'
;
}
}
if
(
pc
->
error
==
PLAYER_ERROR_NOERROR
)
{
if
(
pc
->
error
==
PLAYER_ERROR_NOERROR
)
{
...
...
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