diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-02 18:52:13 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-02 18:52:13 +0000 |
commit | cc1b2c100fc6dd44a690652ecd3c5788b0438ea7 (patch) | |
tree | a3750d996d41e35c5df34c29533dd7d9fdcaff24 /res/res_musiconhold.c | |
parent | 2d6e969e7c81afb0b050691b85f2bc74ca84ae62 (diff) |
bring over all the fixes for the warnings found by gcc 4.3.x from the 1.4 branch, and add the ones needed for all the new code here too
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@153616 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r-- | res/res_musiconhold.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 004934676..fd61cb7a8 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -513,7 +513,10 @@ static int spawn_mp3(struct mohclass *class) ast_close_fds_above_n(STDERR_FILENO); /* 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 { @@ -917,8 +920,8 @@ static int moh_scan_files(struct mohclass *class) { if (class->dir[0] != '/') { ast_copy_string(dir_path, ast_config_AST_VAR_DIR, sizeof(dir_path)); - strncat(dir_path, "/", sizeof(dir_path)); - strncat(dir_path, class->dir, sizeof(dir_path)); + strncat(dir_path, "/", sizeof(dir_path) - 1); + strncat(dir_path, class->dir, sizeof(dir_path) - 1); } else { ast_copy_string(dir_path, class->dir, sizeof(dir_path)); } @@ -934,8 +937,14 @@ static int moh_scan_files(struct mohclass *class) { class->total_files = 0; dirnamelen = strlen(dir_path) + 2; - getcwd(path, sizeof(path)); - chdir(dir_path); + if (!getcwd(path, sizeof(path))) { + ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno)); + return -1; + } + if (chdir(path) < 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)) @@ -972,7 +981,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; + } if (ast_test_flag(class, MOH_SORTALPHA)) qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare); return class->total_files; |