This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit/obvious] Fix possible bug when no args have been provided to the executable
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, Sergio Durigan Junior <sergiodj at redhat dot com>
- Date: Thu, 8 Jun 2017 17:02:29 -0400
- Subject: [commit/obvious] Fix possible bug when no args have been provided to the executable
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D393C05091D
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D393C05091D
- References: <86tw3qa0vd.fsf@gmail.com>
Hi,
This bug is related to:
<https://sourceware.org/ml/gdb-patches/2017-06/msg00216.html>
On stringify_argv, we have to check if args[0] is not NULL before
stringifying anything, otherwise we might do the wrong thing when
trimming the "ret" string in the end. args[0] will be NULL when no
arguments are passed to the inferior that will be started.
Checked in as obvious.
gdb/ChangeLog:
2017-06-08 Sergio Durigan Junior <sergiodj@redhat.com>
* common/common-utils.c (stringify_argv): Check for "arg[0] !=
NULL".
---
gdb/ChangeLog | 5 +++++
gdb/common/common-utils.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 993fabe..5ebc7f8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-08 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * common/common-utils.c (stringify_argv): Check for "arg[0] !=
+ NULL".
+
2017-06-08 Alan Hayward <alan.hayward@arm.com>
* mn10300-tdep.c (MN10300_MAX_REGISTER_SIZE): Add.
diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c
index 793ab3b..e75a1b9 100644
--- a/gdb/common/common-utils.c
+++ b/gdb/common/common-utils.c
@@ -337,7 +337,7 @@ stringify_argv (const std::vector<char *> &args)
{
std::string ret;
- if (!args.empty ())
+ if (!args.empty () && args[0] != NULL)
{
for (auto s : args)
if (s != NULL)
--
2.9.3