From 8ed223343dea58de07322ada8a0dbd7f24a28a24 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 4 Apr 2021 12:51:22 +0200 Subject: [PATCH] getty: fix regression introduced in 5342881 Replacing write() with dprint() without thinking leads to duplicate output in getty. In particular '\n login: foo login: ". Must check if length is > 0, or dprint() will calculate it on its own. Signed-off-by: Joachim Wiberg --- src/getty.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/getty.c b/src/getty.c index a3a6713f..ba0e9f4a 100644 --- a/src/getty.c +++ b/src/getty.c @@ -71,7 +71,8 @@ static void do_parse(char *line, struct utsname *uts, char *tty) s0 = line; for (s = line; *s != 0; s++) { if (*s == '\\') { - dprint(STDOUT_FILENO, s0, s - s0); + if ((s - s0) > 0) + dprint(STDOUT_FILENO, s0, s - s0); s0 = s + 2; switch (*++s) { case 'l': @@ -106,7 +107,8 @@ static void do_parse(char *line, struct utsname *uts, char *tty) } leave: - dprint(STDOUT_FILENO, s0, s - s0); + if ((s - s0) > 0) + dprint(STDOUT_FILENO, s0, s - s0); } /*