From 1189334836027f0d2d5e08ccca07bdd35910f2a7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 26 Oct 2014 23:50:53 +0000 Subject: [PATCH 1/1] * Redact command name characters outside 33-126. --- cprogs/acctdump.c | 15 ++++++++++++--- debian/changelog | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cprogs/acctdump.c b/cprogs/acctdump.c index 0cd7a4e..b9040ac 100644 --- a/cprogs/acctdump.c +++ b/cprogs/acctdump.c @@ -205,17 +205,26 @@ static void printrecord(const struct_acct *as, const char *filename) { struct passwd *pw; struct group *gr; time_t btime; + char commbuf[sizeof(as->ac_comm)]; if (raw) { printf("%10lu ",(unsigned long)as->ac_btime); } else { btime= as->ac_btime; tm= localtime(&btime); - strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",tm); buf[sizeof(buf)-1]= 0; + if (tm) { + strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",tm); buf[sizeof(buf)-1]= 0; + } else { + snprintf(buf,sizeof(buf),"@%lu",(unsigned long)btime); + } printf("%19s ",buf); } - - printf("%-16.16s ", as->ac_comm); + + for (i=0; iac_comm); i++) { + int c=as->ac_comm[i]; + commbuf[i]= ((c!=0 && c<=32) || c>=127) ? '?' : c; + } + printf("%-*.*s ", (int)sizeof(commbuf),(int)sizeof(commbuf), commbuf); pw= raw ? 0 : getpwuid(as->ac_uid); if (pw) printf("%-8s ",pw->pw_name); diff --git a/debian/changelog b/debian/changelog index 6e6babf..0c12866 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,8 @@ chiark-utils (4.4.1) unstable; urgency=low + Safety and convenience fix: + * Redact command name characters outside 33-126. + Portability fixes for platforms where we can't build acctdump: * Do not build on platforms with no -- 2.30.2