From 4dfbdd7823f27c2336fa72a20e8e5122ca0d1266 Mon Sep 17 00:00:00 2001 From: Robert Drehmel Date: Mon, 9 Sep 2002 15:51:10 +0000 Subject: [PATCH] - Fix iBCS2 emulation of COFF files that have multiple libraries in their library (STYP_LIB) section. - Attempt to make the code which calculates the next entry and string offsets look clearer. PR: kern/42580 Tested by: Olaf Klein (on 4.7-PRERELEASE) --- sys/i386/ibcs2/imgact_coff.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/i386/ibcs2/imgact_coff.c b/sys/i386/ibcs2/imgact_coff.c index 0e5363e437a0..8cf447572598 100644 --- a/sys/i386/ibcs2/imgact_coff.c +++ b/sys/i386/ibcs2/imgact_coff.c @@ -389,11 +389,15 @@ exec_coff_imgact(imgp) M_TEMP, M_WAITOK); strcpy(libbuf, ibcs2_emul_path); - for (j = off; j < scns[i].s_size + off; j++) { + for (j = off; j < scns[i].s_size + off;) { + long stroff, nextoff; char *libname; - libname = buf + j + 4 * *(long*)(buf + j + 4); - j += 4* *(long*)(buf + j); + nextoff = 4 * *(long *)(buf + j); + stroff = 4 * *(long *)(buf + j + sizeof(long)); + + libname = buf + j + stroff; + j += nextoff; DPRINTF(("%s(%d): shared library %s\n", __FILE__, __LINE__, libname));