Check the return value of opendir(3), or we may crash.
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 17 Aug 2009 19:57:42 +0000 (19:57 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 17 Aug 2009 19:57:42 +0000 (19:57 +0000)
(closes issue #15720)
 Reported by: tobias_e

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@212627 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 974a029..619754d 100644 (file)
@@ -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;