spv-writer: Avoid obsolete function asctime().
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 7 Feb 2021 04:13:19 +0000 (20:13 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 7 Feb 2021 04:13:19 +0000 (20:13 -0800)
Found by cppcheck.
Reported by John Darrington.

src/output/spv/spv-writer.c

index f1f9b969563f7fab49cf785ae01b19b621212035..549a0d8f849839b01d4fd3907fd8214048ff2746 100644 (file)
@@ -194,8 +194,9 @@ spv_writer_open_file (struct spv_writer *w)
 
   time_t t = time (NULL);
   struct tm *tm = gmtime (&t);
-  char *tm_s = asctime (tm);
-  write_attr (w, "creation-date-time", tm_s);
+  char tm_s[128];
+  if (strftime (tm_s, sizeof tm_s, "%x %X", tm))
+    write_attr (w, "creation-date-time", tm_s);
 
   write_attr (w, "creator", version);