[syslinux:elflink] get_key: Valid key values are positive

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Tue Apr 17 11:27:02 PDT 2012


Commit-ID:  d5e02fb16a11bfdbce1e90a39e6cb5f2ad925389
Gitweb:     http://www.syslinux.org/commit/d5e02fb16a11bfdbce1e90a39e6cb5f2ad925389
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Tue, 17 Apr 2012 11:25:53 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Tue, 17 Apr 2012 11:25:53 -0700

get_key: Valid key values are positive

Make sure we return positive values for valid keystrokes.

Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>

---
 com32/elflink/ldlinux/get_key.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/com32/elflink/ldlinux/get_key.c b/com32/elflink/ldlinux/get_key.c
index 5841d02..0be06b9 100644
--- a/com32/elflink/ldlinux/get_key.c
+++ b/com32/elflink/ldlinux/get_key.c
@@ -167,7 +167,7 @@ int get_key(FILE * f, clock_t timeout)
 	    clock_t lateness = times(NULL) - start;
 	    if (nc && lateness > 1 + KEY_TIMEOUT) {
 		if (nc == 1)
-		    return buffer[0];	/* timeout in sequence */
+		    return (unsigned char)buffer[0];	/* timeout */
 		else if (timeout && lateness > timeout)
 		    return KEY_NONE;
 	    } else if (!nc && timeout && lateness > timeout)
@@ -194,5 +194,5 @@ int get_key(FILE * f, clock_t timeout)
 
     /* We got an unrecognized sequence; return the first character */
     /* We really should remember this and return subsequent characters later */
-    return buffer[0];
+    return (unsigned char)buffer[0];
 }


More information about the Syslinux-commits mailing list