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';

Therefore we have to make sure that two bytes are still free, not just
one.  Not sure why it has to be handled like this, but the fix is easy
to implement, keeping the behaviour.

Thoughts? Okay?


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       11 Jan 2014 11:39:58 -0000
@@ -294,7 +294,7 @@ readline(char *buf, size_t n, int to)
                        continue;
                default:
                        if (ch >= ' ' && ch < '\177') {
-                               if (p - buf < n-1)
+                               if (p - buf < n-2)
                                        *p++ = ch;
                                else {
                                        putchar('\007');

Reply via email to