aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-02-25 18:46:41 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-02-25 18:46:41 +0000
commite4f265b2fce5609d4862cd2d42fd58adf7341299 (patch)
tree1ce9c5b2589f06d2138a060802124cb19b458881
parentca3068d411dc60bf6de2eb88f73c6f91486e8260 (diff)
downloadmpd-e4f265b2fce5609d4862cd2d42fd58adf7341299.tar.gz
mpd-e4f265b2fce5609d4862cd2d42fd58adf7341299.tar.xz
mpd-e4f265b2fce5609d4862cd2d42fd58adf7341299.zip
be more careful with string manipulations, use strncpy as much as possible
git-svn-id: https://svn.musicpd.org/mpd/trunk@56 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.c8
-rw-r--r--src/player.c4
-rw-r--r--src/playerData.c5
3 files changed, 9 insertions, 8 deletions
diff --git a/src/decode.c b/src/decode.c
index 80789337e..ecedc330a 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -108,14 +108,14 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
while(decode_pid>0 && dc->start) usleep(10);
if(dc->start || dc->error!=DECODE_ERROR_NOERROR) {
- strcpy(pc->erroredFile,pc->file);
+ strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_FILE;
quitDecode(pc,dc);
return -1;
}
if(initAudio(af)<0) {
- strcpy(pc->erroredFile,pc->file);
+ strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_AUDIO;
quitDecode(pc,dc);
return -1;
@@ -196,7 +196,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
while(1) {
if(dc->start) {
- strcpy(dc->file,pc->file);
+ strncpy(dc->file,pc->file,MAXPATHLEN);
switch(pc->decodeType) {
#ifdef HAVE_MAD
case DECODE_TYPE_MP3:
@@ -239,7 +239,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
/* END OF CHILD */
}
else if(decode_pid<0) {
- strcpy(pc->erroredFile,pc->file);
+ strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_SYSTEM;
return -1;
}
diff --git a/src/player.c b/src/player.c
index 5cb209334..3b3bf250c 100644
--- a/src/player.c
+++ b/src/player.c
@@ -140,7 +140,7 @@ int playerPlay(FILE * fp, char * utf8file) {
{
struct stat st;
if(stat(rmp2amp(utf8ToFsCharset(utf8file)),&st)<0) {
- strcpy(pc->erroredFile,pc->file);
+ strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_FILENOTFOUND;
return 0;
}
@@ -160,7 +160,7 @@ int playerPlay(FILE * fp, char * utf8file) {
else if(isWave(utf8file)) pc->decodeType = DECODE_TYPE_AUDIOFILE;
#endif
else {
- strcpy(pc->erroredFile,pc->file);
+ strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_UNKTYPE;
return 0;
}
diff --git a/src/playerData.c b/src/playerData.c
index fee8ac719..2976908f2 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -25,6 +25,7 @@
#include <sys/shm.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
int buffered_before_play;
int BUFFERED_CHUNKS;
@@ -102,7 +103,7 @@ void initPlayerData() {
playerData_pd->playerControl.queueState = PLAYER_QUEUE_BLANK;
playerData_pd->playerControl.queueLockState = PLAYER_QUEUE_UNLOCKED;
playerData_pd->playerControl.seek = 0;
- playerData_pd->playerControl.file[0] = '\0';
+ memset(playerData_pd->playerControl.file,0,MAXPATHLEN);
playerData_pd->playerControl.crossFade = crossfade;
playerData_pd->playerControl.softwareVolume = 100;
playerData_pd->playerControl.totalPlayTime = 0;
@@ -112,7 +113,7 @@ void initPlayerData() {
playerData_pd->decoderControl.state = DECODE_STATE_STOP;
playerData_pd->decoderControl.seek = 0;
playerData_pd->decoderControl.error = DECODE_ERROR_NOERROR;
- playerData_pd->decoderControl.file[0] = '\0';
+ memset(playerData_pd->decoderControl.file,0,MAXPATHLEN);
}
PlayerData * getPlayerData() {