[svn-commits] mjordan: branch 13 r433174 - in /branches/13: ./ funcs/ tests/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Mar 19 14:19:53 CDT 2015


Author: mjordan
Date: Thu Mar 19 14:19:51 2015
New Revision: 433174

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433174
Log:
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

Modified:
    branches/13/   (props changed)
    branches/13/funcs/func_env.c
    branches/13/tests/test_func_file.c

Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: branches/13/funcs/func_env.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/funcs/func_env.c?view=diff&rev=433174&r1=433173&r2=433174
==============================================================================
--- branches/13/funcs/func_env.c (original)
+++ branches/13/funcs/func_env.c Thu Mar 19 14:19:51 2015
@@ -561,7 +561,7 @@
 
 			/* 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);

Modified: branches/13/tests/test_func_file.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/tests/test_func_file.c?view=diff&rev=433174&r1=433173&r2=433174
==============================================================================
--- branches/13/tests/test_func_file.c (original)
+++ branches/13/tests/test_func_file.c Thu Mar 19 14:19:51 2015
@@ -63,6 +63,12 @@
 	/* No length */
 	{ "123456789", "-5", "56789" },
 	{ "123456789", "4", "56789" },
+	/* Passed file length */
+	{ "123456789", "8,10", "9" },
+	{ "123456789", "10,1", "" },
+	/* Middle of file */
+	{ "123456789", "2,5", "34567" },
+	{ "123456789", "-7,5", "34567" },
 	/* Line mode, 4 ways of specifying the first character */
 	{ "123\n456\n789\n", "0,1,l", "123\n" },
 	{ "123\n456\n789\n", "-3,1,l", "123\n" },




More information about the svn-commits mailing list