[asterisk-commits] dbailey: branch 1.4 r189391 - in /branches/1.4: channels/ main/ main/db1-ast/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 20 14:10:59 CDT 2009


Author: dbailey
Date: Mon Apr 20 14:10:56 2009
New Revision: 189391

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=189391
Log:
Clean up problem with manager implementation of mmap where it was not testing against MAP_FAILED response.
Got rid of shadowed variable used in processign the mmap results. 
Change test of mmap results to compare against MAP_FAILED

Modified:
    branches/1.4/channels/chan_iax2.c
    branches/1.4/main/db1-ast/recno/rec_open.c
    branches/1.4/main/manager.c

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=189391&r1=189390&r2=189391
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Mon Apr 20 14:10:56 2009
@@ -1967,7 +1967,7 @@
 		return -1;
 	}
 	fwh = (struct ast_iax2_firmware_header*)mmap(NULL, stbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 
-	if (fwh == (void *) -1) {
+	if (fwh == MAP_FAILED) {
 		ast_log(LOG_WARNING, "mmap failed: %s\n", strerror(errno));
 		close(fd);
 		return -1;

Modified: branches/1.4/main/db1-ast/recno/rec_open.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/main/db1-ast/recno/rec_open.c?view=diff&rev=189391&r1=189390&r2=189391
==============================================================================
--- branches/1.4/main/db1-ast/recno/rec_open.c (original)
+++ branches/1.4/main/db1-ast/recno/rec_open.c Mon Apr 20 14:10:56 2009
@@ -169,7 +169,7 @@
 				t->bt_msize = sb.st_size;
 				if ((t->bt_smap = mmap(NULL, t->bt_msize,
 				    PROT_READ, MAP_PRIVATE, rfd,
-				    (off_t)0)) == (caddr_t)-1)
+				    (off_t)0)) == MAP_FAILED
 					goto slow;
 				t->bt_cmap = t->bt_smap;
 				t->bt_emap = t->bt_smap + sb.st_size;

Modified: branches/1.4/main/manager.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/main/manager.c?view=diff&rev=189391&r1=189390&r2=189391
==============================================================================
--- branches/1.4/main/manager.c (original)
+++ branches/1.4/main/manager.c Mon Apr 20 14:10:56 2009
@@ -2881,30 +2881,32 @@
 			char *buf;
 			size_t l = lseek(ss.fd, 0, SEEK_END);
 			if (l) {
-				if ((buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_SHARED, ss.fd, 0))) {
-					char *tmp;
+				if (MAP_FAILED == (buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, ss.fd, 0))) {
+					ast_log(LOG_WARNING, "mmap failed.  Manager request output was not processed\n");
+				} else {
+					char *tmpbuf;
 					if (format == FORMAT_XML)
-						tmp = xml_translate(buf, params);
+						tmpbuf = xml_translate(buf, params);
 					else if (format == FORMAT_HTML)
-						tmp = html_translate(buf);
+						tmpbuf = html_translate(buf);
 					else
-						tmp = buf;
-					if (tmp) {
+						tmpbuf = buf;
+					if (tmpbuf) {
 						size_t wlen, tlen;
-						if ((retval = malloc((wlen = strlen(workspace)) + (tlen = strlen(tmp)) + 128))) {
+						if ((retval = malloc((wlen = strlen(workspace)) + (tlen = strlen(tmpbuf)) + 128))) {
 							strcpy(retval, workspace);
-							strcpy(retval + wlen, tmp);
+							strcpy(retval + wlen, tmpbuf);
 							c = retval + wlen + tlen;
 							/* Leftover space for footer, if any */
 							len = 120;
 						}
 					}
-					if (tmp != buf)
-						free(tmp);
+					if (tmpbuf != buf)
+						free(tmpbuf);
 					free(s->outputstr);
 					s->outputstr = NULL;
+					munmap(buf, l);
 				}
-				munmap(buf, l);
 			}
 			fclose(ss.f);
 			ss.f = NULL;




More information about the asterisk-commits mailing list