Fix invocation of stat() on a NULL pointer.

PR binutils/21407
	* bucomm.c (get_file_size): Return -1 if file_name is NULL.
	* ar.c (main): Fail with usage() invocation if no file names are
	provided.
This commit is contained in:
Nick Clifton 2017-04-26 15:42:03 +01:00
parent 3e6b644558
commit 740a463062
3 changed files with 13 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2017-04-26 Nick Clifton <nickc@redhat.com>
PR binutils/21407
* bucomm.c (get_file_size): Return -1 if file_name is NULL.
* ar.c (main): Fail with usage() invocation if no file names are
provided.
2017-04-26 Nick Clifton <nickc@redhat.com>
* readelf.c (process_section_headers): Warn about overlarge

View File

@ -738,6 +738,9 @@ main (int argc, char **argv)
arg_index = 0;
if (argv[arg_index] == NULL)
usage (0);
if (mri_mode)
{
default_deterministic ();

View File

@ -587,6 +587,9 @@ get_file_size (const char * file_name)
{
struct stat statbuf;
if (file_name == NULL)
return (off_t) -1;
if (stat (file_name, &statbuf) < 0)
{
if (errno == ENOENT)