chiark / gitweb /
* Redact command name characters outside 33-126.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Oct 2014 23:50:53 +0000 (23:50 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 27 Oct 2014 00:14:25 +0000 (00:14 +0000)
cprogs/acctdump.c
debian/changelog

index 0cd7a4e566b6acabf37c809d3cc5651f0bcaaa14..b9040ac710f91eebe6a83af73262a2027a4e4e29 100644 (file)
@@ -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; i<sizeof(as->ac_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);
index 6e6babf7ce77c5f15f2fda7c4665c74d839f986e..0c12866fb62bdf78e611b26d12f511123ead13ec 100644 (file)
@@ -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 <sys/acct.h>