summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/logic/sfrt_map_input.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/logic/sfrt_map_input.c b/src/logic/sfrt_map_input.c
index 77cc40e..d73ace6 100644
--- a/src/logic/sfrt_map_input.c
+++ b/src/logic/sfrt_map_input.c
@@ -29,9 +29,16 @@ int sfrt_map_input(
if ((ret = fstat(fd,&st) < 0) && fnew)
close(fd);
+ else if ((st.st_size == 0) && fnew)
+ close(fd);
+
if (ret < 0)
return SFRT_SYSTEM_ERROR(dctx);
+ else if (st.st_size == 0)
+ return SFRT_CUSTOM_ERROR(
+ dctx,SFRT_ERR_SOURCE_SIZE_ZERO);
+
map->size = st.st_size;
map->addr = mmap(0,map->size,prot,MAP_PRIVATE,fd,0);