This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Correct fscanf char field count


%<number>s as an fscanf format does not include the trailing NULL.
PATH_MAX does include the trailing NULL.

	PR 17453
	* readelf.c (process_program_headers): Correct fscanf format used
	for interpreter.

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 3cf46d8..58ccd93 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4394,7 +4394,7 @@ process_program_headers (FILE * file)
 	  else
 	    {
 	      char fmt [32];
-	      int ret = snprintf (fmt, sizeof (fmt), "%%%ds", PATH_MAX);
+	      int ret = snprintf (fmt, sizeof (fmt), "%%%ds", PATH_MAX - 1);
 
 	      if (ret >= (int) sizeof (fmt) || ret < 0)
 		error (_("Internal error: failed to create format string to display program interpreter\n"));

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]