summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/server.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 08cf013920..39580d008d 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -2058,7 +2058,8 @@ int read_file(int fnum,char *data,uint32 pos,int n)
#if USE_MMAP
if (Files[fnum].mmap_ptr)
{
- int num = MIN(n,(int)(Files[fnum].mmap_size-pos));
+ int num = (Files[fnum].mmap_size > pos) ? (Files[fnum].mmap_size - pos) : -1;
+ num = MIN(n,num);
if (num > 0)
{
memcpy(data,Files[fnum].mmap_ptr+pos,num);