[tip:tools/kvm] kvm tools: Fix term_getc(), term_getc_iov() endian bugs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  e35d5849842c665c1bd966ff030c6d4fea39f4eb
Gitweb:     http://git.kernel.org/tip/e35d5849842c665c1bd966ff030c6d4fea39f4eb
Author:     Matt Evans <matt@xxxxxxxxxx>
AuthorDate: Fri, 9 Dec 2011 17:54:32 +1100
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Fri, 9 Dec 2011 13:50:15 +0200

kvm tools: Fix term_getc(), term_getc_iov() endian bugs

term_getc()'s int c has one byte written into it (at its lowest address) by
read_in_full().  This is expected to be the least significant byte, but that
isn't the case on BE!  Use correct type, unsigned char.  A similar issue exists
in term_getc_iov(), which needs to write a char to the iov rather than an int.

Signed-off-by: Matt Evans <matt@xxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/term.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/kvm/term.c b/tools/kvm/term.c
index fb5d71c..b7d8934 100644
--- a/tools/kvm/term.c
+++ b/tools/kvm/term.c
@@ -30,16 +30,13 @@ int term_fds[4][2];
 
 int term_getc(int who, int term)
 {
-	int c;
+	unsigned char c;
 
 	if (who != active_console)
 		return -1;
-
 	if (read_in_full(term_fds[term][TERM_FD_IN], &c, 1) < 0)
 		return -1;
 
-	c &= 0xff;
-
 	if (term_got_escape) {
 		term_got_escape = false;
 		if (c == 'x')
@@ -84,7 +81,7 @@ int term_getc_iov(int who, struct iovec *iov, int iovcnt, int term)
 	if (c < 0)
 		return 0;
 
-	*((int *)iov[TERM_FD_IN].iov_base)	= c;
+	*((char *)iov[TERM_FD_IN].iov_base)	= (char)c;
 
 	return sizeof(char);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux