From a5329e8499e915d7c88e3852750c325f074ee537 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Mon, 17 Aug 2009 19:58:52 +0000 Subject: [PATCH] Merged revisions 212627 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r212627 | tilghman | 2009-08-17 14:57:42 -0500 (Mon, 17 Aug 2009) | 4 lines 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/branches/1.6.0@212628 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_voicemail.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 3f7f1c2207..c72f5311bf 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3031,7 +3031,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;