From e9dcd4a9e2a3d2b2f7e38f321aef92cc35d38367 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Tue, 8 Feb 2011 16:19:17 +0000 Subject: [PATCH] make this safer and fully correct, pointed out by Steve Davis git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@306864 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_voicemail.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index e593ade46e..37e1c6bb55 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -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) {