]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
GDB crash with empty executable name (MinGW).
authorJoel Brobecker <brobecker@gnat.com>
Fri, 8 Jan 2010 13:54:40 +0000 (13:54 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Fri, 8 Jan 2010 13:54:40 +0000 (13:54 +0000)
        * source.c (openp): Add assert that parameter string is not NULL.
        if parameter string is an empty string, then return with a failure
        immediately.

gdb/ChangeLog
gdb/source.c

index 707b2f20be2422d56913e70e4fdca92422fdf9e7..cb49ab9ddbfc466457087569406afb59d17d60e8 100644 (file)
@@ -1,3 +1,10 @@
+2009-01-08  Joel Brobecker  <brobecker@adacore.com>
+
+       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.
+
 2009-01-08  Joel Brobecker  <brobecker@adacore.com>
 
        Get rid of support for VAX Floats.
index fcfce65a327bbceef68149b139417bf8691d7d48..209032657163b85a3b87500e082c1c62a0ef80e8 100644 (file)
@@ -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 = ".";