summaryrefslogtreecommitdiff
path: root/preload
diff options
context:
space:
mode:
authorLauri Aarnio <Lauri.Aarnio@iki.fi>2008-10-29 00:54:15 +0200
committerLauri Leukkunen <lle@rahina.org>2008-11-02 18:59:55 +0200
commit3a51c776ff15fcc89be17f51f9109862ed4ea09f (patch)
tree8d34b3e348fa8ebe3f052ff1936192700524c9bd /preload
parenta7357a2051b7d0835f5dc00153a084846d06df43 (diff)
Bugfix: inspect_binary() crashed when the file was empty - min.size of an executable is now 4 bytes. Smaller files are rejected. - sb2-show: better diagnostics, if "sb2-show exec" fails.
Diffstat (limited to 'preload')
-rw-r--r--preload/sb_exec.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/preload/sb_exec.c b/preload/sb_exec.c
index bee8e97..80084fe 100644
--- a/preload/sb_exec.c
+++ b/preload/sb_exec.c
@@ -371,6 +371,14 @@ static enum binary_type inspect_binary(const char *filename)
goto _out_close;
}
+ if (status.st_size < 4) {
+ SB_LOG(SB_LOGLEVEL_DEBUG,
+ "File size is too small, can't exec (%s)", filename);
+ errno = ENOEXEC;
+ retval = BIN_NONE;
+ goto _out_close;
+ }
+
region = mmap(0, status.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (!region) {
goto _out_close;