[asterisk-commits] tilghman: branch 1.4 r278023 - /branches/1.4/main/manager.c

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


Author: tilghman
Date: Tue Jul 20 11:37:18 2010
New Revision: 278023

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=278023
Log:
Off-by-one error

(closes issue #16506)
 Reported by: nik600
 Patches: 
       20100629__issue16506.diff.txt uploaded by tilghman (license 14)

Modified:
    branches/1.4/main/manager.c

Modified: branches/1.4/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/main/manager.c?view=diff&rev=278023&r1=278022&r2=278023
==============================================================================
--- branches/1.4/main/manager.c (original)
+++ branches/1.4/main/manager.c Tue Jul 20 11:37:18 2010
@@ -2917,14 +2917,12 @@
 			char *buf;
 			size_t l;
 
-			/* Ensure buffer is NULL-terminated */
-			fprintf(ss.f, "%c", 0);
-
 			if ((l = lseek(ss.fd, 0, SEEK_END)) > 0) {
-				if (MAP_FAILED == (buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, ss.fd, 0))) {
+				if (MAP_FAILED == (buf = mmap(NULL, l + 1, PROT_READ | PROT_WRITE, MAP_SHARED, ss.fd, 0))) {
 					ast_log(LOG_WARNING, "mmap failed.  Manager request output was not processed\n");
 				} else {
 					char *tmpbuf;
+					buf[l] = '\0';
 					if (format == FORMAT_XML)
 						tmpbuf = xml_translate(buf, params);
 					else if (format == FORMAT_HTML)
@@ -2945,7 +2943,7 @@
 						free(tmpbuf);
 					free(s->outputstr);
 					s->outputstr = NULL;
-					munmap(buf, l);
+					munmap(buf, l + 1);
 				}
 			}
 			fclose(ss.f);




More information about the asterisk-commits mailing list