Welcome to little lamb

Code » anopa » commit 52dfae6

tty: Fix possibly printing garbage; Closes #1

author Olivier Brunel
2015-08-27 11:54:04 UTC
committer Olivier Brunel
2015-08-27 11:54:04 UTC
parent 5819ddfbaa4f3edd165c9b4a01426e5b55e99249

tty: Fix possibly printing garbage; Closes #1

name isn't NULL-terminated, so when printing it we need to ensure only
using the right number of characters.

Thanks to John O'Meara

src/utils/aa-tty.c +3 -1

diff --git a/src/utils/aa-tty.c b/src/utils/aa-tty.c
index 88f8acd..233f9ca 100644
--- a/src/utils/aa-tty.c
+++ b/src/utils/aa-tty.c
@@ -93,6 +93,8 @@ main (int argc, char * const argv[])
 
     for (;;)
     {
+        int l = r;
+
         byte_copy (file + sizeof (PREFIX) - 1, r, name);
         byte_copy (file + sizeof (PREFIX) - 2 + r, sizeof (NAME), NAME);
         r = openreadnclose (file, name, max);
@@ -101,7 +103,7 @@ main (int argc, char * const argv[])
             if (errno == ENOENT)
             {
                 aa_bs_noflush (AA_OUT, "/dev/");
-                aa_bs_flush (AA_OUT, name);
+                aa_bb_flush (AA_OUT, name, l);
                 return 0;
             }
             else