diff mbox series

Fix off-by-one in simple-object-elf.c (PR lto/91228).

Message ID 9a3d4bfe-aa4c-2fbb-2e95-0e41f510e91f@suse.cz
State New
Headers show
Series Fix off-by-one in simple-object-elf.c (PR lto/91228). | expand

Commit Message

Martin Liška July 24, 2019, 6:59 a.m. UTC
Hi.

The patch is about off-by-one error that I used for a wrong argument.
I consider that pre-approved by Richi.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Thanks,
Martin

libiberty/ChangeLog:

2019-07-23  Martin Liska  <mliska@suse.cz>

	PR lto/91228
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Find first '\0' starting from gnu_lto + 1.
---
 libiberty/simple-object-elf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
index bdee963634d..75159266596 100644
--- a/libiberty/simple-object-elf.c
+++ b/libiberty/simple-object-elf.c
@@ -1388,8 +1388,8 @@  simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
 				       (unsigned char *)strings,
 				       strsz, &errmsg, err);
 	  /* Find first '\0' in strings.  */
-	  gnu_lto = (char *) memchr (gnu_lto, '\0',
-				     strings + strsz - gnu_lto + 1);
+	  gnu_lto = (char *) memchr (gnu_lto + 1, '\0',
+				     strings + strsz - gnu_lto);
 	  /* Read the section index table if present.  */
 	  if (symtab_indices_shndx[i - 1] != 0)
 	    {