Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa PR/43830: Valery Ushakov: libsa/loadfile_elf32...
details: https://anonhg.NetBSD.org/src/rev/f4753aa77350
branches: trunk
changeset: 757535:f4753aa77350
user: christos <christos%NetBSD.org@localhost>
date: Thu Sep 02 17:10:14 2010 +0000
description:
PR/43830: Valery Ushakov: libsa/loadfile_elf32.c loads .shstrtab into
unallocated memory. Don't load if counting.
diffstat:
sys/lib/libsa/loadfile_elf32.c | 64 ++++++++++++++++++++++-------------------
1 files changed, 34 insertions(+), 30 deletions(-)
diffs (79 lines):
diff -r ed3e5378a7ef -r f4753aa77350 sys/lib/libsa/loadfile_elf32.c
--- a/sys/lib/libsa/loadfile_elf32.c Thu Sep 02 16:55:15 2010 +0000
+++ b/sys/lib/libsa/loadfile_elf32.c Thu Sep 02 17:10:14 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile_elf32.c,v 1.25 2010/03/12 21:43:11 darran Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.26 2010/09/02 17:10:14 christos Exp $ */
/*-
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@@ -411,36 +411,40 @@
* First load the section names section.
*/
if (boot_load_ctf && (elf->e_shstrndx != 0)) {
- if (lseek(fd, shp[elf->e_shstrndx].sh_offset,
- SEEK_SET) == -1) {
- WARN(("lseek symbols"));
- goto freeshp;
- }
- nr = READ(fd, maxp, shp[elf->e_shstrndx].sh_size);
- if (nr == -1) {
- WARN(("read symbols"));
- goto freeshp;
- }
- if (nr != (ssize_t)shp[elf->e_shstrndx].sh_size) {
- errno = EIO;
- WARN(("read symbols"));
- goto freeshp;
- }
+ if (flags & LOAD_SYM) {
+ if (lseek(fd, shp[elf->e_shstrndx].sh_offset,
+ SEEK_SET) == -1) {
+ WARN(("lseek symbols"));
+ goto freeshp;
+ }
+ nr = READ(fd, maxp,
+ shp[elf->e_shstrndx].sh_size);
+ if (nr == -1) {
+ WARN(("read symbols"));
+ goto freeshp;
+ }
+ if (nr !=
+ (ssize_t)shp[elf->e_shstrndx].sh_size) {
+ errno = EIO;
+ WARN(("read symbols"));
+ goto freeshp;
+ }
- shstr = ALLOC(shp[elf->e_shstrndx].sh_size);
- if (lseek(fd, shp[elf->e_shstrndx].sh_offset,
- SEEK_SET) == -1) {
- WARN(("lseek symbols"));
- goto freeshp;
- }
- nr = read(fd, shstr, shp[elf->e_shstrndx].sh_size);
- if (nr == -1) {
- WARN(("read symbols"));
- goto freeshp;
- }
-
- shp[elf->e_shstrndx].sh_offset = maxp - elfp;
- maxp += roundup(shp[elf->e_shstrndx].sh_size, ELFROUND);
+ shstr = ALLOC(shp[elf->e_shstrndx].sh_size);
+ if (lseek(fd, shp[elf->e_shstrndx].sh_offset,
+ SEEK_SET) == -1) {
+ WARN(("lseek symbols"));
+ goto freeshp;
+ }
+ nr = read(fd, shstr,
+ shp[elf->e_shstrndx].sh_size);
+ if (nr == -1) {
+ WARN(("read symbols"));
+ goto freeshp;
+ }
+ }
+ shp[elf->e_shstrndx].sh_offset = maxp - elfp;
+ maxp += roundup(shp[elf->e_shstrndx].sh_size, ELFROUND);
}
/*
Home |
Main Index |
Thread Index |
Old Index