]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
make this safer and fully correct, pointed out by Steve Davis
authorJeff Peeler <jpeeler@digium.com>
Tue, 8 Feb 2011 16:19:17 +0000 (16:19 +0000)
committerJeff Peeler <jpeeler@digium.com>
Tue, 8 Feb 2011 16:19:17 +0000 (16:19 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@306864 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index e593ade46e511f8a4a2431ceb03231dd3effe3a4..37e1c6bb55029965c831cfc341d760a4b187ea48 100644 (file)
@@ -2925,7 +2925,7 @@ static int last_message_index(struct ast_vm_user *vmu, char *dir)
        DIR *msgdir;
        struct dirent *msgdirent;
        int msgdirint;
-       char extension[3];
+       char extension[4];
        int stopcount = 0;
 
        /* Reading the entire directory into a file map scales better than
@@ -2937,7 +2937,7 @@ static int last_message_index(struct ast_vm_user *vmu, char *dir)
        }
 
        while ((msgdirent = readdir(msgdir))) {
-               if (sscanf(msgdirent->d_name, "msg%30d.%3s", &msgdirint, extension) == 2 && msgdirint < MAXMSGLIMIT && !strcmp(extension, "txt")) {
+               if (!strcmp(extension, "txt") && msgdirint < MAXMSGLIMIT && sscanf(msgdirent->d_name, "msg%10d.%3s", &msgdirint, extension) == 2) {
                        map[msgdirint] = 1;
                        stopcount++;
                        if (option_debug > 3) {