Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] GDB crash with empty executable name (MinGW)
Date: Fri, 08 Jan 2010 13:59:00 -0000	[thread overview]
Message-ID: <20100108135904.GG29312@adacore.com> (raw)
In-Reply-To: <m3my0sa1kp.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

> I think it would be fine, but I would recommend putting some info into
> the comment explaining why this check was added... just some detail from
> your original note.

Agreed. Here is what I checked in. I can make additional adjustments
if necessary.

Thank you!
-- 
Joel

[-- Attachment #2: source.diff --]
[-- Type: text/x-diff, Size: 1182 bytes --]

commit f15ba96bbf48880f5a60443e78bab39070a5fc33
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Fri Jan 8 16:15:54 2010 +0400

    GDB crash with empty executable name (MinGW).
    
            * source.c (openp): Add assert that parameter string is not NULL.
            if parameter string is an empty string, then return with a failure
            immediately.

diff --git a/gdb/source.c b/gdb/source.c
index fcfce65..2090326 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -707,6 +707,20 @@ openp (const char *path, int opts, const char *string,
 
   /* The open syscall MODE parameter is not specified.  */
   gdb_assert ((mode & O_CREAT) == 0);
+  gdb_assert (string != NULL);
+
+  /* A file with an empty name cannot possibly exist.  Report a failure
+     without further checking.
+
+     This is an optimization which also defends us against buggy
+     implementations of the "stat" function.  For instance, we have
+     noticed that a MinGW debugger built on Windows XP 32bits crashes
+     when the debugger is started with an empty argument.  */
+  if (string[0] == '\0')
+    {
+      errno = ENOENT;
+      return -1;
+    }
 
   if (!path)
     path = ".";

      reply	other threads:[~2010-01-08 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-02 12:47 Joel Brobecker
2010-01-02 19:34 ` Christopher Faylor
2010-01-02 21:38 ` Michael
2010-01-05 17:45 ` Tom Tromey
2010-01-08 13:59   ` Joel Brobecker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100108135904.GG29312@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox