mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-27 14:41:58 +00:00
Eliminate a file descriptor leak when using the FILE() dialplan function.
(closes issue #18731) Reported by: marioabajo git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@305844 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -499,6 +499,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
|
|||||||
|
|
||||||
if (fseeko(ff, 0, SEEK_END) < 0) {
|
if (fseeko(ff, 0, SEEK_END) < 0) {
|
||||||
ast_log(LOG_ERROR, "Cannot seek to end of '%s': %s\n", args.filename, strerror(errno));
|
ast_log(LOG_ERROR, "Cannot seek to end of '%s': %s\n", args.filename, strerror(errno));
|
||||||
|
fclose(ff);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
flength = ftello(ff);
|
flength = ftello(ff);
|
||||||
@@ -511,6 +512,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
|
|||||||
fseeko(ff, length, SEEK_END);
|
fseeko(ff, length, SEEK_END);
|
||||||
if ((length = ftello(ff)) - offset < 0) {
|
if ((length = ftello(ff)) - offset < 0) {
|
||||||
/* Eliminates all results */
|
/* Eliminates all results */
|
||||||
|
fclose(ff);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (length == LLONG_MAX) {
|
} else if (length == LLONG_MAX) {
|
||||||
@@ -537,6 +539,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
|
|||||||
|
|
||||||
ast_str_append_substr(buf, len, fbuf, toappend);
|
ast_str_append_substr(buf, len, fbuf, toappend);
|
||||||
}
|
}
|
||||||
|
fclose(ff);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,6 +704,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(ff);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,6 +776,8 @@ static int file_write(struct ast_channel *chan, const char *cmd, char *data, con
|
|||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
if (fseeko(ff, offset, SEEK_END)) {
|
if (fseeko(ff, offset, SEEK_END)) {
|
||||||
ast_log(LOG_ERROR, "Cannot seek to offset: %s\n", strerror(errno));
|
ast_log(LOG_ERROR, "Cannot seek to offset: %s\n", strerror(errno));
|
||||||
|
fclose(ff);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
offset = ftello(ff);
|
offset = ftello(ff);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user