PATCH: binutils/3384: readelf displays shortened program interpreter path

Nick Clifton nickc@redhat.com
Sun Oct 29 20:49:00 GMT 2006


Hi H. J.

> 2006-10-24  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	PR binutils/3384
> 	* configure.in (AC_CHECK_HEADERS): Add limits.h and sys/param.h.
> 	* configure: Regenerated.
> 	* config.in: Likewise.
> 
> 	* readelf.c: Include <limits.h> and <sys/param.h> for PATH_MAX.
> 	(program_interpreter): Allocate PATH_MAX bytes instead of 64.
> 	(process_program_headers): Don't assume that program interpreter
> 	is shorter than 64 characters.

Approved, please apply, but...


> +	      char fmt [32];
> +	      int ret = snprintf (fmt, sizeof (fmt), "%%%ds", PATH_MAX);
> +
> +	      if (ret >= (int) sizeof (fmt) || ret < 0)
> +		error (_("Failed to print program interpreter name\n"));

It strikes me that this error message is wrong.  Since what we have 
failed to do is to construct a format string that can be used to print 
the program interpreter name.  Since this should never reasonably happen 
(PATH_MAX would have to be a huge number), this really ought to be an 
internal error.  So how about:

   error (_("Internal error: failed to create format string to display 
program interpreter"));

Cheers
   Nick



More information about the Binutils mailing list