summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2016-02-02 22:27:48 +0000
committergjb <gjb@FreeBSD.org>2016-02-02 22:27:48 +0000
commitefd5551e55b056811a107b33e1c30676ee37d0e8 (patch)
tree5ea64f05cc16d8a5032524fdefec823e707e1ff3 /libexec
parenta6998ad84f9722c560a80302a74fa495e818a153 (diff)
parent6d511d769313fd1dae574a1d395369df219e86b6 (diff)
downloadFreeBSD-src-efd5551e55b056811a107b33e1c30676ee37d0e8.zip
FreeBSD-src-efd5551e55b056811a107b33e1c30676ee37d0e8.tar.gz
MFH
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'libexec')
-rw-r--r--libexec/atrun/atrun.c3
-rw-r--r--libexec/rtld-elf/map_object.c12
2 files changed, 11 insertions, 4 deletions
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c
index 1e25766..7b11e7b 100644
--- a/libexec/atrun/atrun.c
+++ b/libexec/atrun/atrun.c
@@ -459,8 +459,9 @@ main(int argc, char *argv[])
int c;
int run_batch;
#ifdef __FreeBSD__
- size_t ncpu, ncpusz;
+ size_t ncpusz;
double load_avg = -1;
+ int ncpu;
#else
double load_avg = LOADAVG_MX;
#endif
diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c
index 6012015..f4f6f42 100644
--- a/libexec/rtld-elf/map_object.c
+++ b/libexec/rtld-elf/map_object.c
@@ -38,7 +38,7 @@
#include "debug.h"
#include "rtld.h"
-static Elf_Ehdr *get_elf_header(int, const char *);
+static Elf_Ehdr *get_elf_header(int, const char *, const struct stat *);
static int convert_prot(int); /* Elf flags -> mmap protection */
static int convert_flags(int); /* Elf flags -> mmap flags */
@@ -91,7 +91,7 @@ map_object(int fd, const char *path, const struct stat *sb)
char *note_map;
size_t note_map_len;
- hdr = get_elf_header(fd, path);
+ hdr = get_elf_header(fd, path, sb);
if (hdr == NULL)
return (NULL);
@@ -324,10 +324,16 @@ error:
}
static Elf_Ehdr *
-get_elf_header(int fd, const char *path)
+get_elf_header(int fd, const char *path, const struct stat *sbp)
{
Elf_Ehdr *hdr;
+ /* Make sure file has enough data for the ELF header */
+ if (sbp != NULL && sbp->st_size < sizeof(Elf_Ehdr)) {
+ _rtld_error("%s: invalid file format", path);
+ return (NULL);
+ }
+
hdr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE | MAP_PREFAULT_READ,
fd, 0);
if (hdr == (Elf_Ehdr *)MAP_FAILED) {
OpenPOWER on IntegriCloud