summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2006-07-18 07:27:41 +0000
committerNathan Sidwell <nathan@codesourcery.com>2006-07-18 07:27:41 +0000
commit0ed1cc44f49e922675518790ac62bb9e7fa36219 (patch)
tree066703acfe52c4c176f31061268ec930a819061a
parentdd37895b5a5106b5092daf1c831d6e6db9ce5b83 (diff)
downloadgdb-0ed1cc44f49e922675518790ac62bb9e7fa36219.tar.gz
gdb/
* remote-fileio.c (remote_fileio_func_rename): Reorder to process input buffer before reading memory. (remote_fileio_func_stat): Likewise.
-rw-r--r--ChangeLog.csl7
-rw-r--r--gdb/remote-fileio.c55
2 files changed, 37 insertions, 25 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 6bbe8a54888..2f67cc01d5e 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,10 @@
+2006-07-18 Nathan Sidwell <nathan@codesourcery.com>
+
+ gdb/
+ * remote-fileio.c (remote_fileio_func_rename): Reorder to process
+ input buffer before reading memory.
+ (remote_fileio_func_stat): Likewise.
+
2006-07-16 Nathan Sidwell <nathan@codesourcery.com>
gdb/
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index e8195279635..b76fc27e582 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -938,36 +938,39 @@ remote_fileio_func_lseek (char *buf)
static void
remote_fileio_func_rename (char *buf)
{
- CORE_ADDR ptrval;
- int length, retlength;
+ CORE_ADDR old_ptr, new_ptr;
+ int old_len, new_len, retlength;
char *oldpath, *newpath;
int ret, of, nf;
struct stat ost, nst;
/* 1. Parameter: Ptr to oldpath / length incl. trailing zero */
- if (remote_fileio_extract_ptr_w_len (&buf, &ptrval, &length))
+ if (remote_fileio_extract_ptr_w_len (&buf, &old_ptr, &old_len))
{
remote_fileio_ioerror ();
return;
}
- /* Request oldpath using 'm' packet */
- oldpath = alloca (length);
- retlength = remote_read_bytes (ptrval, (gdb_byte *) oldpath, length);
- if (retlength != length)
+
+ /* 2. Parameter: Ptr to newpath / length incl. trailing zero */
+ if (remote_fileio_extract_ptr_w_len (&buf, &new_ptr, &new_len))
{
remote_fileio_ioerror ();
return;
}
- /* 2. Parameter: Ptr to newpath / length incl. trailing zero */
- if (remote_fileio_extract_ptr_w_len (&buf, &ptrval, &length))
+
+ /* Request oldpath using 'm' packet */
+ oldpath = alloca (old_len);
+ retlength = remote_read_bytes (old_ptr, (gdb_byte *) oldpath, old_len);
+ if (retlength != old_len)
{
remote_fileio_ioerror ();
return;
}
+
/* Request newpath using 'm' packet */
- newpath = alloca (length);
- retlength = remote_read_bytes (ptrval, (gdb_byte *) newpath, length);
- if (retlength != length)
+ newpath = alloca (new_len);
+ retlength = remote_read_bytes (new_ptr, (gdb_byte *) newpath, new_len);
+ if (retlength != new_len)
{
remote_fileio_ioerror ();
return;
@@ -1070,35 +1073,36 @@ remote_fileio_func_unlink (char *buf)
static void
remote_fileio_func_stat (char *buf)
{
- CORE_ADDR ptrval;
- int ret, length, retlength;
+ CORE_ADDR statptr, nameptr;
+ int ret, namelength, retlength;
char *pathname;
LONGEST lnum;
struct stat st;
struct fio_stat fst;
/* 1. Parameter: Ptr to pathname / length incl. trailing zero */
- if (remote_fileio_extract_ptr_w_len (&buf, &ptrval, &length))
+ if (remote_fileio_extract_ptr_w_len (&buf, &nameptr, &namelength))
{
remote_fileio_ioerror ();
return;
}
- /* Request pathname using 'm' packet */
- pathname = alloca (length);
- retlength = remote_read_bytes (ptrval, (gdb_byte *) pathname, length);
- if (retlength != length)
+
+ /* 2. Parameter: Ptr to struct stat */
+ if (remote_fileio_extract_long (&buf, &lnum))
{
remote_fileio_ioerror ();
return;
}
-
- /* 2. Parameter: Ptr to struct stat */
- if (remote_fileio_extract_long (&buf, &lnum))
+ statptr = (CORE_ADDR) lnum;
+
+ /* Request pathname using 'm' packet */
+ pathname = alloca (namelength);
+ retlength = remote_read_bytes (nameptr, (gdb_byte *) pathname, namelength);
+ if (retlength != namelength)
{
remote_fileio_ioerror ();
return;
}
- ptrval = (CORE_ADDR) lnum;
remote_fio_no_longjmp = 1;
ret = stat (pathname, &st);
@@ -1114,12 +1118,13 @@ remote_fileio_func_stat (char *buf)
remote_fileio_reply (-1, FILEIO_EACCES);
return;
}
- if (ptrval)
+ if (statptr)
{
remote_fileio_to_fio_stat (&st, &fst);
remote_fileio_to_fio_uint (0, fst.fst_dev);
- retlength = remote_fileio_write_bytes (ptrval, (gdb_byte *) &fst, sizeof fst);
+ retlength = remote_fileio_write_bytes (statptr,
+ (gdb_byte *) &fst, sizeof fst);
if (retlength != sizeof fst)
{
remote_fileio_return_errno (-1);