[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-tech
Subject:    boot: off-by-one
From:       Tobias Stoeckmann <tobias () stoeckmann ! org>
Date:       2014-06-26 18:57:11
Message-ID: 20140626185711.GA6580 () fungi ! pizza ! local
[Download RAW message or body]

Hi,

in boot, we have an off-by-one error in readline.  When the user ends
input with enter, the string will be ended twice, like:

    p[1] = *p = '\0';

Comparing readline with read_conf (reading commands from file),
there is no need to "double end" the input line.


Tobias

Index: cmd.c
===================================================================
RCS file: /cvs/src/sys/stand/boot/cmd.c,v
retrieving revision 1.61
diff -u -p -r1.61 cmd.c
--- cmd.c	23 Dec 2013 23:32:40 -0000	1.61
+++ cmd.c	26 Jun 2014 18:55:02 -0000
@@ -283,7 +283,7 @@ readline(char *buf, size_t n, int to)
 			continue;
 		case '\n':
 		case '\r':
-			p[1] = *p = '\0';
+			*p = '\0';
 			break;
 		case '\b':
 		case '\177':

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic