From: Tilghman Lesher Date: Mon, 17 Aug 2009 20:00:06 +0000 (+0000) Subject: Merged revisions 212627 via svnmerge from X-Git-Tag: 1.6.1.7-rc1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b3dadaaf40895403088dde3463f02848c3cb45b;p=thirdparty%2Fasterisk.git 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.1@212630 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index b34899bd71..b72d0ddf04 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3447,7 +3447,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;