X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/bcacc18bdf1bdac625ef1f178e8e32892544cc30..5d6bcd4472d7a88adc9be81987f02b58332e432c:/util.c diff --git a/util.c b/util.c index e39f3cc1..357b8308 100644 --- a/util.c +++ b/util.c @@ -47,8 +47,12 @@ struct map_struct *map_file(int fd,OFF_T len) ret->p_len = 0; #ifdef HAVE_MMAP - if (len < MAX_MAP_SIZE) - ret->map = (char *)mmap(NULL,len,PROT_READ,MAP_SHARED,fd,0); + if (len < MAX_MAP_SIZE) { + ret->map = (char *)mmap(NULL,len,PROT_READ,MAP_SHARED,fd,0); + if (ret->map == (char *)-1) { + ret->map = NULL; + } + } #endif return ret; } @@ -83,7 +87,7 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len) map->p_size = len; } - if (lseek(map->fd,offset,SEEK_SET) != offset || + if (do_lseek(map->fd,offset,SEEK_SET) != offset || (nread=read(map->fd,map->p,len)) != len) { fprintf(FERROR,"EOF in map_ptr! (offset=%d len=%d nread=%d errno=%d)\n", (int)offset, len, nread, errno);