This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Fix invocation of stat() on a NULL pointer.
- From: Nick Clifton <nickc at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 26 Apr 2017 14:42:35 -0000
- Subject: [binutils-gdb] Fix invocation of stat() on a NULL pointer.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=740a463062bd5d1641bdfb639295dafe89341b9b
commit 740a463062bd5d1641bdfb639295dafe89341b9b
Author: Nick Clifton <nickc@redhat.com>
Date: Wed Apr 26 15:42:03 2017 +0100
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.
Diff:
---
binutils/ChangeLog | 7 +++++++
binutils/ar.c | 3 +++
binutils/bucomm.c | 3 +++
3 files changed, 13 insertions(+)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index e1736b9..b37d5b3 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,12 @@
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
sections.
(print_gnu_build_attribute_name): Print the number of unrecognised
diff --git a/binutils/ar.c b/binutils/ar.c
index 32ac404..ef8b5bd 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -738,6 +738,9 @@ main (int argc, char **argv)
arg_index = 0;
+ if (argv[arg_index] == NULL)
+ usage (0);
+
if (mri_mode)
{
default_deterministic ();
diff --git a/binutils/bucomm.c b/binutils/bucomm.c
index e682717..fd6f356 100644
--- a/binutils/bucomm.c
+++ b/binutils/bucomm.c
@@ -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)