summaryrefslogtreecommitdiffstats
path: root/lib/libelf/elf_scn.c
diff options
context:
space:
mode:
authorkaiw <kaiw@FreeBSD.org>2010-07-21 10:25:02 +0000
committerkaiw <kaiw@FreeBSD.org>2010-07-21 10:25:02 +0000
commit49a7d97ce43a82f9cfa863a35ca5cc928d7caf1e (patch)
tree49e27eb10d72ea7dccf8d6dc7232254e881bb052 /lib/libelf/elf_scn.c
parent800d46f6e4936589dbbae5ddea8fe956c0cc7500 (diff)
downloadFreeBSD-src-49a7d97ce43a82f9cfa863a35ca5cc928d7caf1e.zip
FreeBSD-src-49a7d97ce43a82f9cfa863a35ca5cc928d7caf1e.tar.gz
Perform additional checks when translating between file and memory
representations of ELF types. The ELF(3) API allows applications to request a conversion that is `in-place', i.e., with source and destinations data buffers being the same. However, the file and memory sizes of ELF sections that have additional internal structure, such as those of type `Elf_Note', or `Elf_GNU_Hash_Header', can be determined only known after the type-specific headers that comprise the first few words in these sections are read and translated. Pass in the size of destination buffer to type translation routines in "libelf_convert.m4" and have these routines return an error code if the translated data would not fit inside the destination buffer. Obtained from: elftoolchain MFC after: 1 month
Diffstat (limited to 'lib/libelf/elf_scn.c')
-rw-r--r--lib/libelf/elf_scn.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libelf/elf_scn.c b/lib/libelf/elf_scn.c
index 3a9e575..2eefca1 100644
--- a/lib/libelf/elf_scn.c
+++ b/lib/libelf/elf_scn.c
@@ -48,7 +48,7 @@ _libelf_load_scn(Elf *e, void *ehdr)
Elf32_Ehdr *eh32;
Elf64_Ehdr *eh64;
Elf_Scn *scn;
- void (*xlator)(char *_d, char *_s, size_t _c, int _swap);
+ int (*xlator)(char *_d, size_t _dsz, char *_s, size_t _c, int _swap);
assert(e != NULL);
assert(ehdr != NULL);
@@ -101,7 +101,8 @@ _libelf_load_scn(Elf *e, void *ehdr)
if ((scn = _libelf_allocate_scn(e, i)) == NULL)
return (0);
- (*xlator)((char *) &scn->s_shdr, src, (size_t) 1, swapbytes);
+ (*xlator)((char *) &scn->s_shdr, sizeof(scn->s_shdr), src,
+ (size_t) 1, swapbytes);
if (ec == ELFCLASS32) {
scn->s_offset = scn->s_rawoff =
OpenPOWER on IntegriCloud