[PATCH 07/16] last: use carefulput() for printable character output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 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 0f475f2..f08632b 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');
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux