shallow clone: unparse and reparse an unshallowed commit
[gitweb.git] / compat / mmap.c
index a051c4767dfad8d8083051fe18aa9cfdba83b5f9..a4d2e507f73c5595a2ca76c0369349cc11e2426f 100644 (file)
@@ -2,11 +2,12 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include "../cache.h"
+#include "../git-compat-util.h"
 
 void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)
 {
        int n = 0;
+       off_t current_offset = lseek(fd, 0, SEEK_CUR);
 
        if (start != NULL || !(flags & MAP_PRIVATE))
                die("Invalid usage of gitfakemmap.");
@@ -39,6 +40,11 @@ void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_
                n += count;
        }
 
+       if (current_offset != lseek(fd, current_offset, SEEK_SET)) {
+               errno = EINVAL;
+               return MAP_FAILED;
+       }
+
        return start;
 }