]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Clean up problem with manager implementation of mmap where it was not testing against...
authorDoug Bailey <dbailey@digium.com>
Mon, 20 Apr 2009 19:10:56 +0000 (19:10 +0000)
committerDoug Bailey <dbailey@digium.com>
Mon, 20 Apr 2009 19:10:56 +0000 (19:10 +0000)
Got rid of shadowed variable used in processign the mmap results.
Change test of mmap results to compare against MAP_FAILED

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@189391 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
main/db1-ast/recno/rec_open.c
main/manager.c

index 71056e61896d72ca40acaf24bc5b4a53ae65f4cf..fc36e8eeba513408b6850c5ff158a47e2364bbd4 100644 (file)
@@ -1967,7 +1967,7 @@ static int try_firmware(char *s)
                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;
index 0ebc8c7c49b3cf1791c87720789c54b30bed2b62..0fb08258c8b8977f80ebeb0510050455f9066e14 100644 (file)
@@ -169,7 +169,7 @@ slow:                       if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
                                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;
index 65b6d88175ffd314e7c51715865b89aad32dc402..d54874547922bf9cd47bf6a4aa3ae811679bd4e4 100644 (file)
@@ -2881,30 +2881,32 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
                        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;