dect
/
asterisk
Archived
13
0
Fork 0

Check the return value of opendir(3), or we may crash.

(closes issue #15720)
 Reported by: tobias_e


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@212627 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
tilghman 2009-08-17 19:57:42 +00:00
parent be1a867384
commit ff93d9c264
1 changed files with 4 additions and 1 deletions

View 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;