]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: make output more robust
authorKarel Zak <kzak@redhat.com>
Thu, 11 Oct 2018 11:29:39 +0000 (13:29 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 11 Oct 2018 11:29:39 +0000 (13:29 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index 6072694ef487e5f599ec1d40ce40e499f89527af..d6703d4f0c93880ff699c691ff32339a2b1c1581 100644 (file)
@@ -1790,20 +1790,25 @@ static void print_issue_file(struct issue *ie,
                }
        }
 
-       write_all(STDOUT_FILENO, ie->mem, ie->mem_sz);
+       if (ie->mem_sz)
+               write_all(STDOUT_FILENO, ie->mem, ie->mem_sz);
+
        if (ie->do_tcrestore) {
                /* Restore settings. */
                tp->c_oflag = oflag;
                /* Wait till output is gone. */
                tcsetattr(STDIN_FILENO, TCSADRAIN, tp);
        }
+
 #ifdef AGETTY_RELOAD
        free(ie->mem_old);
        ie->mem_old = ie->mem;
        ie->mem = NULL;
+       ie->mem_sz = 0;
 #else
        free(ie->mem);
        ie->mem = NULL;
+       ie->mem_sz = 0;
 #endif
 }