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:
parent
be1a867384
commit
ff93d9c264
|
@ -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;
|
||||
|
|
Reference in New Issue