From 363d8186a0da4dd21c2beacec05920a71ab67022 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Tue, 6 Nov 2018 14:05:59 +0000 Subject: [PATCH] 9833 elfedit dumps core on incorrect file Reviewed by: Igor Kozhukhov Reviewed by: Alexander Pyhalov Reviewed by: Michal Nowak Reviewed by: Jason King Approved by: Hans Rosenfeld --- usr/src/cmd/sgs/elfedit/common/elfedit_machelf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/usr/src/cmd/sgs/elfedit/common/elfedit_machelf.c b/usr/src/cmd/sgs/elfedit/common/elfedit_machelf.c index 73653cd6e2..b5094e39c3 100644 --- a/usr/src/cmd/sgs/elfedit/common/elfedit_machelf.c +++ b/usr/src/cmd/sgs/elfedit/common/elfedit_machelf.c @@ -22,6 +22,7 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -229,15 +230,16 @@ elfedit32_init_obj_state(const char *file, int fd, Elf *elf) /*LINTED E_BAD_PTR_CAST_ALIGN*/ obj_state->os_secarr = (elfedit_section_t *) ((char *)obj_state + os_size); - if (obj_state->os_symtabnum == 0) + if (obj_state->os_symtabnum == 0) { obj_state->os_symtab = NULL; - else + } else { /*LINTED E_BAD_PTR_CAST_ALIGN*/ obj_state->os_symtab = (elfedit_symtab_t *) ((char *)obj_state->os_secarr + secarr_size); - obj_state->os_file = - (char *)(obj_state->os_symtab + tstate.os_symtabnum); - (void) strncpy((char *)obj_state->os_file, tstate.os_file, len); + obj_state->os_file = + (char *)(obj_state->os_symtab + tstate.os_symtabnum); + (void) strncpy((char *)obj_state->os_file, tstate.os_file, len); + } /* * Fill in obj_state->os_secarr with information for each section. -- 2.11.4.GIT