]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Fixed mmap()ing of zero-sized files (Robin H. Johnson)
authormortenp <none@none>
Thu, 30 Oct 2008 19:13:09 +0000 (06:13 +1100)
committermortenp <none@none>
Thu, 30 Oct 2008 19:13:09 +0000 (06:13 +1100)
ChangeLog
src/getaddrsfromfd.c
src/mlmmj-list.c

index 32afaa46314ea193eded76ebffd669b984eff6ca..71b44ebf485cc9997fbc9b758ad2c9a73aec0e5c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+ o Fixed mmap()ing of zero-sized files (Robin H. Johnson)
  o Fixed mlmmj-recieve [sic] for architectures where
    sizeof(int) and sizeof(char *) differ
  o Added support for the 'originalmail' keyword (Sascha Sommer)
index ecd785401a8252f3f09c007c9608524f747418aa..6e23940c639e77714bbf6659453e7d8877d96b93 100644 (file)
@@ -21,6 +21,10 @@ off_t getaddrsfromfd(struct strlist *slist, int fd, int max)
                log_error(LOG_ARGS, "Could not fstat fd");
                return -1;
        }
+       /* mmap of 0-bytes is invalid */
+       if(st.st_size == 0) {
+               return 0;
+       }
 
        start = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
        if(start == MAP_FAILED) {
index 049a0f9b96876a5e2685b443377435230384a4c6..c1e42fc1469402a25f11b192ddf3759fb3afb209 100644 (file)
@@ -68,6 +68,11 @@ int dumpcount(const char *filename, int *count)
        
        if(!S_ISREG(st.st_mode))
                return -1;
+       
+       /* Nobody there */
+       if(st.st_size == 0) {
+               return 0;
+       }
 
        start = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
        if(start == MAP_FAILED)