aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/remote-utils.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-12-30 15:44:51 +0000
committerDaniel Jacobowitz <drow@false.org>2006-12-30 15:44:51 +0000
commit8264bb58d66b04ee787f18e5cb6a54f6cc75e620 (patch)
tree5dfb1df37d747c2029957397323cd1358cc21209 /gdb/gdbserver/remote-utils.c
parent03fa9f0e991d53341620fb552ca90f302131a74b (diff)
downloadgdb-8264bb58d66b04ee787f18e5cb6a54f6cc75e620.zip
gdb-8264bb58d66b04ee787f18e5cb6a54f6cc75e620.tar.gz
gdb-8264bb58d66b04ee787f18e5cb6a54f6cc75e620.tar.bz2
* remote-utils.c (remote_open): Check the type of specified
serial port devices before opening them. * server.c (main): Kill the inferior if an error occurs during the first remote_open.
Diffstat (limited to 'gdb/gdbserver/remote-utils.c')
-rw-r--r--gdb/gdbserver/remote-utils.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index fd5c844..80c6343 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -52,6 +52,8 @@
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
+#include <sys/stat.h>
+#include <errno.h>
#if USE_WIN32API
#include <winsock.h>
@@ -94,13 +96,25 @@ remote_open (char *name)
#if defined(F_SETFL) && defined (FASYNC)
int save_fcntl_flags;
#endif
-
- if (!strchr (name, ':'))
+ char *port_str;
+
+ port_str = strchr (name, ':');
+ if (port_str == NULL)
{
#ifdef USE_WIN32API
error ("Only <host>:<port> is supported on this platform.");
#else
- remote_desc = open (name, O_RDWR);
+ struct stat statbuf;
+
+ if (stat (name, &statbuf) == 0
+ && (S_ISCHR (statbuf.st_mode) || S_ISFIFO (statbuf.st_mode)))
+ remote_desc = open (name, O_RDWR);
+ else
+ {
+ errno = EINVAL;
+ remote_desc = -1;
+ }
+
if (remote_desc < 0)
perror_with_name ("Could not open remote device");