diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2009-08-17 19:57:42 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2009-08-17 19:57:42 +0000 |
commit | c2612973d06260da55509bdd1c209ceee72ceff7 (patch) | |
tree | 4301e6d8cb34c5e22befe90e01c44d1c44766615 /apps/app_voicemail.c | |
parent | 4c47fce62e807cb0d473cc6583caf93d444e7982 (diff) |
Check the return value of opendir(3), or we may crash.
(closes issue #15720)
Reported by: tobias_e
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@212627 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r-- | apps/app_voicemail.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 974a02961..619754db6 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3576,7 +3576,10 @@ static int last_message_index(struct ast_vm_user *vmu, char *dir) * doing a stat repeatedly on a predicted sequence. I suspect this * is partially due to stat(2) internally doing a readdir(2) itself to * find each file. */ - msgdir = opendir(dir); + if (!(msgdir = opendir(dir))) { + return -1; + } + while ((msgdirent = readdir(msgdir))) { if (sscanf(msgdirent->d_name, "msg%30d", &msgdirint) == 1 && msgdirint < MAXMSGLIMIT) map[msgdirint] = 1; |