From: Sami Kerola Date: Sat, 17 Aug 2013 18:15:12 +0000 (+0100) Subject: last: use carefulput() for printable character output X-Git-Tag: v2.24-rc1~341 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e58cd407e41937f7ca82a19577ac0198d77cceb;p=thirdparty%2Futil-linux.git last: use carefulput() for printable character output Signed-off-by: Sami Kerola --- 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');