Fixed small buffer in get_datetime()
authorVincent Loupmon <vincentloupmon@gmail.com>
Thu, 10 Mar 2016 09:53:14 +0000 (10:53 +0100)
committerVincent Loupmon <vincentloupmon@gmail.com>
Thu, 10 Mar 2016 09:53:14 +0000 (10:53 +0100)
The buffer being hardcoded to 19 (the size expected from the default time format),
strftime() would fail on any format returning a longer buffer.
Changed it from 19 to 64 to accomodate longer formats.

slstatus.c

index 331a34540394cead67fa3fee71ca6b05333ea2f0..28a8caa0b9ff280a2c6972e6d9a8c034386044d1 100644 (file)
@@ -143,13 +143,13 @@ char *
 get_datetime()
 {
     time_t tm;
-    size_t bufsize = 19;
+    size_t bufsize = 64;
     char *buf = malloc(bufsize);
 
     /* get time in format */
     time(&tm);
     if(!strftime(buf, bufsize, timeformat, localtime(&tm))) {
-        fprintf(stderr, "Strftime failed.\n");
+      fprintf(stderr, "Strftime failed.\n");
         exit(1);
     }