From f67e617a26e6d1efafb752d5047b4ddc33056ab1 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 28 Feb 2005 16:07:33 +0000 Subject: [PATCH] (pe_ILF_build_a_bfd): Do not assume that an @ will be present when IMPORT_NAME_UNDOECRATE is used. --- bfd/ChangeLog | 5 +++++ bfd/peicode.h | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a0cc726edd..69634157f2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2005-02-28 Ross Ridge + + * peicode.h (pe_ILF_build_a_bfd): Do not assume that an @ will be + present when IMPORT_NAME_UNDOECRATE is used. + 2005-02-28 H.J. Lu PR 757 diff --git a/bfd/peicode.h b/bfd/peicode.h index 1282bb9b1c..7d5f361ef9 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -865,6 +865,7 @@ pe_ILF_build_a_bfd (bfd * abfd, else { char * symbol; + unsigned int len; /* Create .idata$6 - the Hint Name Table. */ id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); @@ -909,19 +910,21 @@ pe_ILF_build_a_bfd (bfd * abfd, while (check_again); } + len = strlen (symbol); if (import_name_type == IMPORT_NAME_UNDECORATE) { - /* Truncate at the first '@' */ - while (* symbol != 0 && * symbol != '@') - symbol ++; + /* Truncate at the first '@'. */ + char *at = strchr (symbol, '@'); - * symbol = 0; + if (at != NULL) + len = at - symbol; } id6->contents[0] = ordinal & 0xff; id6->contents[1] = ordinal >> 8; - strcpy ((char *) id6->contents + 2, symbol); + memcpy ((char *) id6->contents + 2, symbol, len); + id6->contents[len + 2] = '\0'; } if (import_name_type != IMPORT_ORDINAL)