apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sander Striker" <stri...@apache.org>
Subject RE: mmap bug?
Date Fri, 28 Feb 2003 13:22:46 GMT
> From: Ian Holsman [mailto:ianh@apache.org]
> Sent: Friday, February 28, 2003 12:22 AM

> Sander Striker wrote:
>>>From: Joe Orton [mailto:joe@manyfish.co.uk]
>>>Sent: Thursday, February 27, 2003 10:32 PM
> 
>> 
>> Yah, from the flurry of failures I've seen on the subversion list I've
>> learned enough :(.
>> 
>> I guess we need to always return APR_EINVAL when a 0 sized mmap is requested.
>> 
>> Sander
> 
> before we do this, what will happen (before & after this change)

This being the patch at the bottom...

> if someone requests a zero-length file.
> 1. with sendfile turned on
> 2. with sendfile turned off (which I think then uses mmap)

You are thinking in httpd terms...  See an my post to dev@httpd.
 
Can someone at home in the file buckets take a look at these:

buckets/apr_buckets_file.c:93:        if (apr_mmap_create(&mm, a->fd, fileoffset, APR_MMAP_LIMIT,
buckets/apr_buckets_file.c:102:             (apr_mmap_create(&mm, a->fd, fileoffset,
filelength,

And see if 0 length files are handled correctly?

Sander


Index: mmap/unix/mmap.c
===================================================================
RCS file: /home/cvs/apr/mmap/unix/mmap.c,v
retrieving revision 1.47
diff -u -r1.47 mmap.c
--- mmap/unix/mmap.c    7 Jan 2003 00:52:55 -0000       1.47
+++ mmap/unix/mmap.c    28 Feb 2003 13:21:43 -0000
@@ -122,6 +122,9 @@
     apr_int32_t native_flags = 0;
 #endif

+    if (size == 0)
+        return APR_EINVAL;
+
     if (file == NULL || file->filedes == -1 || file->buffered)
         return APR_EBADF;
     (*new) = (apr_mmap_t *)apr_pcalloc(cont, sizeof(apr_mmap_t));
cvs server: Diffing mmap/win32
Index: mmap/win32/mmap.c
===================================================================
RCS file: /home/cvs/apr/mmap/win32/mmap.c,v
retrieving revision 1.18
diff -u -r1.18 mmap.c
--- mmap/win32/mmap.c   7 Jan 2003 00:52:55 -0000       1.18
+++ mmap/win32/mmap.c   28 Feb 2003 13:21:43 -0000
@@ -123,7 +123,10 @@
         mvaccess |= FILE_MAP_READ;
     if (flag & APR_MMAP_WRITE)
         mvaccess |= FILE_MAP_WRITE;
-
+
+    if (size == 0)
+        return APR_EINVAL;
+
     if (!file || !file->filehand || file->filehand == INVALID_HANDLE_VALUE
         || file->buffered)
         return APR_EBADF;


Mime
View raw message