[asterisk-commits] tilghman: trunk r278024 - in /trunk: ./ main/manager.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 20 11:50:19 CDT 2010


Author: tilghman
Date: Tue Jul 20 11:50:11 2010
New Revision: 278024

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=278024
Log:
Merged revisions 278023 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r278023 | tilghman | 2010-07-20 11:37:18 -0500 (Tue, 20 Jul 2010) | 7 lines
  
  Off-by-one error
  
  (closes issue #16506)
   Reported by: nik600
   Patches: 
         20100629__issue16506.diff.txt uploaded by tilghman (license 14)
........

Modified:
    trunk/   (props changed)
    trunk/main/manager.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=278024&r1=278023&r2=278024
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Jul 20 11:50:11 2010
@@ -5523,19 +5523,17 @@
 		char *buf;
 		size_t l;
 
-		/* Ensure buffer is NULL-terminated */
-		fprintf(s.f, "%c", 0);
-
 		if ((l = ftell(s.f))) {
-			if (MAP_FAILED == (buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, s.fd, 0))) {
+			if (MAP_FAILED == (buf = mmap(NULL, l + 1, PROT_READ | PROT_WRITE, MAP_PRIVATE, s.fd, 0))) {
 				ast_log(LOG_WARNING, "mmap failed.  Manager output was not processed\n");
 			} else {
+				buf[l] = '\0';
 				if (format == FORMAT_XML || format == FORMAT_HTML) {
 					xml_translate(&out, buf, params, format);
 				} else {
 					ast_str_append(&out, 0, "%s", buf);
 				}
-				munmap(buf, l);
+				munmap(buf, l + 1);
 			}
 		} else if (format == FORMAT_XML || format == FORMAT_HTML) {
 			xml_translate(&out, "", params, format);




More information about the asterisk-commits mailing list