diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-01 18:22:39 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-01 18:22:39 +0000 |
commit | ea96823f2626e2a4178eec54f8a78a666d376ac1 (patch) | |
tree | d6fd63606de3355d2e0f7bb2ab751116095a1451 /res/res_musiconhold.c | |
parent | 1c4fdfd503883d806ba05da5d0e9156b54a4d51b (diff) |
fix a bunch of potential problems found by gcc 4.3.x, primarily bare strings being passed to printf()-like functions and ignored results from read()/write() and friends
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@153337 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r-- | res/res_musiconhold.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index ed2b55f0e..255f8d5d9 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -482,7 +482,10 @@ static int spawn_mp3(struct mohclass *class) } } /* Child */ - chdir(class->dir); + if (chdir(class->dir) < 0) { + ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno)); + _exit(1); + } if (ast_test_flag(class, MOH_CUSTOM)) { execv(argv[0], argv); } else { @@ -817,8 +820,14 @@ static int moh_scan_files(struct mohclass *class) { class->total_files = 0; dirnamelen = strlen(class->dir) + 2; - getcwd(path, sizeof(path)); - chdir(class->dir); + if (!getcwd(path, sizeof(path))) { + ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno)); + return -1; + } + if (chdir(class->dir) < 0) { + ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno)); + return -1; + } while ((files_dirent = readdir(files_DIR))) { /* The file name must be at least long enough to have the file type extension */ if ((strlen(files_dirent->d_name) < 4)) @@ -857,7 +866,10 @@ static int moh_scan_files(struct mohclass *class) { } closedir(files_DIR); - chdir(path); + if (chdir(path) < 0) { + ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno)); + return -1; + } return class->total_files; } |