summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-24 20:41:57 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:52 -0500
commit84192873bf59ccdb97cfd751130f072c258acbe7 (patch)
tree31e931fff146de6e2784c8a4357a5a8883618308
parent9a46b6d0483006a8b6e25d2f33f393ec6f16808f (diff)
downloadperk-84192873bf59ccdb97cfd751130f072c258acbe7.tar.bz2
perk-84192873bf59ccdb97cfd751130f072c258acbe7.tar.xz
pe_map_raw_image(): improved error trace logic.
-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);