summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2015-03-19 19:19:51 +0000
committerMatthew Jordan <mjordan@digium.com>2015-03-19 19:19:51 +0000
commit73dcea59bd17c694e636a886e151863c02311822 (patch)
tree160dfc57de49b39a8640c8a61ff83337edbcea13 /funcs
parent4c84dca2d82f9a3461dae3cac8e596309770586f (diff)
funcs/func_env: Fix regression caused in FILE read operation
When r432935 was merged, it did correctly fix a situation where a FILE read operation on the middle of a file buffer would not read the requested length in the parameters passed to the FILE function. Unfortunately, it would also allow the FILE function to append more bytes than what was available in the buffer if the length exceeded the end of the buffer length. This patch takes the minimum of the remaining bytes in the buffer along with the calculated length to append provided by the original patch, and uses that as the length to append in the return result. This patch also updates the unit tests with the scenarios that were originally pointed out in ASTERISK-21765 that the original implementation treated incorrectly. ASTERISK-21765 ........ Merged revisions 433173 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433174 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_env.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/funcs/func_env.c b/funcs/func_env.c
index 0daa7f48d..26bd09c13 100644
--- a/funcs/func_env.c
+++ b/funcs/func_env.c
@@ -561,7 +561,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
/* Don't go past the length requested */
if (off_i + toappend > offset + length) {
- toappend = offset + length - off_i;
+ toappend = MIN(offset + length - off_i, flength - off_i);
}
ast_str_append_substr(buf, len, fbuf, toappend);