From fa66afbd4e3ec9abd384ff7b2c754e4d545079e2 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Sat, 2 Jan 2010 13:44:04 +0100 Subject: [PATCH] GDB crash with empty executable name. * 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/source.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/gdb/source.c b/gdb/source.c index 661bbd6..9f8376a 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -707,6 +707,14 @@ 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. */ + if (string[0] == '\0') + { + errno = ENOENT; + return -1; + } if (!path) path = "."; -- 1.5.5.1