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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-04-04 12:54:35 +02:00
1 parent 90f7ff1c23
commit 8ed223343d
1 file changed
+4 -2
+4 -2
View File
@@ -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);
}
/*