Author: cfinck
Date: Wed Apr 15 01:53:25 2009
New Revision: 40511

URL: http://svn.reactos.org/svn/reactos?rev=40511&view=rev
Log:
Don't miss the last byte when we have nothing more to read

Modified:
    trunk/tools/sysreg2/console.c

Modified: trunk/tools/sysreg2/console.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/console.c?rev=40511&r1=40510&r2=40511&view=diff
==============================================================================
--- trunk/tools/sysreg2/console.c [iso-8859-1] (original)
+++ trunk/tools/sysreg2/console.c [iso-8859-1] Wed Apr 15 01:53:25 2009
@@ -72,8 +72,8 @@
 
             bp = buf;
 
-            /* Read one line or a maximum of 512 bytes into a buffer */
-            while (bp - buf < sizeof(buf))
+            /* Read one line or a maximum of 511 bytes into a buffer (leave 
space for the null character) */
+            while (bp - buf < sizeof(buf) - 1)
             {
                 got = read(fds[i].fd, bp, 1);
 
@@ -89,8 +89,10 @@
                 }
 
                 /* Also break on newlines */
-                if(*bp++ == '\n')
+                if(*bp == '\n')
                     break;
+
+                ++bp;
             }
 
             if (bp == buf)
@@ -99,8 +101,8 @@
                 Ret = EXIT_SHUTDOWN;
                 goto cleanup;
             }
-                
-            *bp = 0;
+
+            *(++bp) = 0;
 
             /* Now check the output */
             if (fds[i].fd == STDIN_FILENO)

Reply via email to