summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/logic/pe_map_raw_image.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/logic/pe_map_raw_image.c b/src/logic/pe_map_raw_image.c
index 4c6ec92..f7f0df3 100644
--- a/src/logic/pe_map_raw_image.c
+++ b/src/logic/pe_map_raw_image.c
@@ -35,9 +35,15 @@ int pe_map_raw_image(
if ((ret = fstat(fd,&st) < 0) && fnew)
close(fd);
+ else if ((st.st_size == 0) && fnew)
+ close(fd);
+
if (ret < 0)
return PERK_SYSTEM_ERROR(dctx);
+ else if (st.st_size == 0)
+ return PERK_CUSTOM_ERROR(dctx,0);
+
map->size = st.st_size;
map->addr = mmap(0,map->size,prot,MAP_PRIVATE,fd,0);