~ubuntu-branches/ubuntu/raring/clamav/raring

« back to all changes in this revision

Viewing changes to m4/mmap_private.m4

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2008-09-05 17:25:34 UTC
  • mfrom: (0.35.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080905172534-yi3f8fkye1o7u1r3
* New upstream version (closes: #497662, #497773)
  - lots of new options for clamd.conf
  - fixes CVEs CVE-2008-3912, CVE-2008-3913, CVE-2008-3914, and
    CVE-2008-1389
* No longer supports --unzip option, so typo is gone (closes: #496276)
* Translations:
  - sv (thanks Martin Bagge <brother@bsnet.se>) (closes: #491760)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl Check for mmap()
 
2
dnl AC_FUNC_MMAP checks for private fixed mappings, we don't need
 
3
dnl fixed mappings, so check only wether private mappings work.
 
4
dnl AC_FUNC_MMAP would fail on HP-UX for example.
 
5
AC_DEFUN([AC_C_FUNC_MMAP_PRIVATE],
 
6
 
7
        AC_CACHE_CHECK([for working mmap], [ac_cv_c_mmap_private],
 
8
        [
 
9
                AC_RUN_IFELSE([AC_LANG_SOURCE([
 
10
#include <unistd.h>
 
11
#include <stdlib.h>
 
12
#include <sys/mman.h>
 
13
#ifdef HAVE_SYS_TYPES_H
 
14
#include <sys/types.h>
 
15
#endif
 
16
#ifdef HAVE_SYS_STAT_H
 
17
#include <sys/stat.h>
 
18
#endif
 
19
#include <fcntl.h> 
 
20
int main(void)
 
21
{
 
22
        char *data, *data2, *data3;
 
23
        unsigned i, datasize = 1024;
 
24
        int fd;
 
25
 
 
26
        /* First, make a file with some known garbage in it. */
 
27
        data = (char*) malloc(datasize);
 
28
        if(!data)
 
29
                return 1;
 
30
        for(i=0;i<datasize;i++)
 
31
                *(data + i) = rand();
 
32
        umask(0);
 
33
        fd = creat("conftest.mmap", 0600);
 
34
        if(fd < 0)
 
35
                return 1;
 
36
        if(write (fd, data, datasize) != datasize)
 
37
                return 1;
 
38
        close(fd);
 
39
        fd = open("conftest.mmap", O_RDWR);
 
40
        if (fd < 0)
 
41
                return 1;
 
42
        /* Next, try to mmap the file at a fixed address which already has
 
43
           something else allocated at it.  If we can, also make sure that
 
44
           we see the same garbage.  */
 
45
        data2 = mmap(NULL, sizeof(data), PROT_READ | PROT_WRITE,
 
46
                MAP_PRIVATE, fd, 0L);   
 
47
        if(data2 == MAP_FAILED)
 
48
                return 2;
 
49
        for(i=0;i<sizeof(data);i++)
 
50
                if(*(data + i) != *(data2+ i))
 
51
                        return 3;
 
52
          /* Finally, make sure that changes to the mapped area do not
 
53
             percolate back to the file as seen by read().  (This is a bug on
 
54
             some variants of i386 svr4.0.)  */
 
55
          for (i = 0; i < datasize; ++i)
 
56
            *(data2 + i) = *(data2 + i) + 1;
 
57
        data3 = (char*) malloc(datasize);
 
58
        if(!data3)
 
59
                return 1;
 
60
        if(read (fd, data3, datasize) != datasize)
 
61
                return 1;
 
62
        for(i=0;i<sizeof(data);i++)
 
63
                if(*(data + i) != *(data3 + i))
 
64
                        return 3;
 
65
        close(fd);
 
66
        return 0;
 
67
}])],
 
68
        [ac_cv_c_mmap_private=yes],
 
69
        [ac_cv_c_mmap_private=no],
 
70
        [ac_cv_c_mmap_private=no])])
 
71
if test $ac_cv_c_mmap_private = yes; then
 
72
        AC_DEFINE(HAVE_MMAP, 1,
 
73
                [Define to 1 if you have a working `mmap' system call that supports MAP_PRIVATE.])
 
74
fi
 
75
rm -f conftest.mmap
 
76
])
 
77
 
 
78
 
 
79