[Crash-utility] [PATCH v2 2/7] remote_proc_version: NULL terminate passed buffer on error.

Don Slutz dslutz at verizon.com
Wed Nov 20 01:33:38 UTC 2013


From: Don Slutz <dslutz at verizon.com>

Also add cpu argumnet to remote_memory_read.

Signed-off-by: Don Slutz <dslutz at verizon.com>
---
 defs.h   | 2 +-
 memory.c | 4 ++--
 remote.c | 8 ++++++--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/defs.h b/defs.h
index a5299cc..86b4fae 100755
--- a/defs.h
+++ b/defs.h
@@ -5535,7 +5535,7 @@ int remote_memory_used(void);
 void remote_exit(void);
 int remote_execute(void);
 void remote_clear_pipeline(void);
-int remote_memory_read(int, char *, int, physaddr_t);
+int remote_memory_read(int, char *, int, physaddr_t, int);
 
 /*
  *  gnu_binutils.c
diff --git a/memory.c b/memory.c
index d936b53..5ec454d 100755
--- a/memory.c
+++ b/memory.c
@@ -2492,7 +2492,7 @@ write_lkcd_dumpfile(int fd, void *bufptr, int cnt, ulong addr, physaddr_t paddr)
 int
 read_daemon(int fd, void *bufptr, int cnt, ulong vaddr, physaddr_t paddr) 
 {
-	if (remote_memory_read(pc->rmfd, bufptr, cnt, paddr) == cnt)
+	if (remote_memory_read(pc->rmfd, bufptr, cnt, paddr, -1) == cnt)
 		return cnt;
 
 	if (!IS_VMALLOC_ADDR(vaddr) || DUMPFILE())
@@ -2506,7 +2506,7 @@ read_daemon(int fd, void *bufptr, int cnt, ulong vaddr, physaddr_t paddr)
          *  the only alternative is to read it from /dev/kmem.
          */
 
-	if (BITS32() && remote_memory_read(pc->rkfd, bufptr, cnt, vaddr) == cnt)
+	if (BITS32() && remote_memory_read(pc->rkfd, bufptr, cnt, vaddr, -1) == cnt)
                 return cnt;
 
 	return READ_ERROR;
diff --git a/remote.c b/remote.c
index 95ce03d..204f7b8 100755
--- a/remote.c
+++ b/remote.c
@@ -2281,8 +2281,10 @@ remote_proc_version(char *buf)
         sprintf(sendbuf, "PROC_VERSION");
         remote_tcp_write_string(pc->sockfd, sendbuf);
         remote_tcp_read_string(pc->sockfd, recvbuf, BUFSIZE-1, NIL_MODE());
-        if (STREQ(recvbuf, "<FAIL>"))
+        if (STREQ(recvbuf, "<FAIL>")) {
+		buf[0] = 0;
                 return FALSE;
+	}
         strcpy(buf, recvbuf);
 	return TRUE;
 }
@@ -3470,7 +3472,7 @@ remote_memory_dump(int verbose)
  *  a page in length.
  */
 int 
-remote_memory_read(int rfd, char *buffer, int cnt, physaddr_t address)
+remote_memory_read(int rfd, char *buffer, int cnt, physaddr_t address, int vcpu)
 {
         char sendbuf[BUFSIZE];
 	char datahdr[DATA_HDRSIZE];
@@ -3489,6 +3491,8 @@ remote_memory_read(int rfd, char *buffer, int cnt, physaddr_t address)
                 sprintf(sendbuf, "READ_LKCD %d %lx %d", rfd, addr, cnt);
         else if (pc->flags & REM_S390D)
                 sprintf(sendbuf, "READ_S390D %d %lx %d", rfd, addr, cnt);
+        else if (vcpu >= 0)
+                sprintf(sendbuf, "READ_LIVE %d %lx %d %d", rfd, addr, cnt, vcpu);
         else
                 sprintf(sendbuf, "READ_LIVE %d %lx %d", rfd, addr, cnt);
 
-- 
1.8.4




More information about the Crash-utility mailing list