From 2e58cd407e41937f7ca82a19577ac0198d77cceb Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 17 Aug 2013 19:15:12 +0100 Subject: [PATCH] last: use carefulput() for printable character output Signed-off-by: Sami Kerola --- login-utils/last.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/login-utils/last.c b/login-utils/last.c index 0f475f2cfd..f08632bbf0 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -45,6 +45,7 @@ #include "pathnames.h" #include "xalloc.h" #include "closestream.h" +#include "carefulputc.h" #ifndef SHUTDOWN_TIME # define SHUTDOWN_TIME 254 @@ -396,12 +397,8 @@ static int list(struct utmp *p, time_t t, int what) /* * Print out "final" string safely. */ - for (s = final; *s; s++) { - if (*s == '\n' || (*s >= 32 && (unsigned char)*s <= 126)) - putchar(*s); - else - putchar('*'); - } + for (s = final; *s; s++) + carefulputc(*s, stdout, '*'); if (len < 0 || (size_t)len >= sizeof(final)) putchar('\n'); -- 2.47.2