[binutils-gdb] Fix snafu parsing $ORIGIN.

Nick Clifton nickc@sourceware.org
Thu Nov 24 10:00:00 GMT 2016


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=51750acd087cc20ae3f72393fa897d9e3059c65d

commit 51750acd087cc20ae3f72393fa897d9e3059c65d
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Nov 24 10:00:20 2016 +0000

    Fix snafu parsing $ORIGIN.
    
    	PR ld/20858
    	* emultempl/elf32.em (_search_needed): Allow for path separator
    	and terminating NUL byte when allocating space for new $ORIGIN
    	path.

Diff:
---
 ld/ChangeLog          | 7 +++++++
 ld/emultempl/elf32.em | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 9c5eb40..0747409 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2016-11-24  Nick Clifton  <nickc@redhat.com>
+
+	PR ld/20858
+	* emultempl/elf32.em (_search_needed): Allow for path separator
+	and terminating NUL byte when allocating space for new $ORIGIN
+	path.
+
 2016-11-23  Nick Clifton  <nickc@redhat.com>
 
 	* testsuite/ld-arm/vxworks2.sd: Update expected readelf output.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 8c63638..f5cb3ee 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -585,7 +585,7 @@ gld${EMULATION_NAME}_search_needed (const char *path,
 			{
 			  char * current_dir = getpwd ();
 
-			  freeme = xmalloc (strlen (replacement) + strlen (current_dir));
+			  freeme = xmalloc (strlen (replacement) + strlen (current_dir) + 2);
 			  sprintf (freeme, "%s/%s", current_dir, replacement);
 			}



More information about the Binutils-cvs mailing list