[exim-cvs] Compiler quietening

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] Compiler quietening
Gitweb: https://git.exim.org/exim.git/commitdiff/b09c5f34a0b1e9dec95e0f4955735e752293b223
Commit:     b09c5f34a0b1e9dec95e0f4955735e752293b223
Parent:     7d4064fb2ca678359a6fa29a30a00c08fa75e70a
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Mon Nov 4 12:43:27 2019 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Mon Nov 4 12:44:11 2019 +0000


    Compiler quietening
---
 src/src/functions.h |  2 +-
 src/src/tod.c       | 30 +++++++++++++++---------------
 2 files changed, 16 insertions(+), 16 deletions(-)


diff --git a/src/src/functions.h b/src/src/functions.h
index 35f8b6c..eca8e79 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -937,7 +937,7 @@ static uschar buf[sizeof("0.000s")];
if (diff->tv_sec >= 5 || !LOGGING(millisec))
return readconf_printtime((int)diff->tv_sec);

-sprintf(CS buf, "%u.%03us", (uint)diff->tv_sec, (uint)diff->tv_usec/1000);
+snprintf(CS buf, sizeof(buf), "%u.%03us", (uint)diff->tv_sec, (uint)diff->tv_usec/1000);
return buf;
}

diff --git a/src/src/tod.c b/src/src/tod.c
index 9088fc6..e7123f9 100644
--- a/src/src/tod.c
+++ b/src/src/tod.c
@@ -62,17 +62,17 @@ gettimeofday(&now, NULL);
 switch(type)
   {
   case tod_epoch:
-    (void) sprintf(CS timebuf, TIME_T_FMT, now.tv_sec);  /* Unix epoch format */
+    (void) snprintf(CS timebuf, sizeof(timebuf), TIME_T_FMT, now.tv_sec);  /* Unix epoch format */
     return timebuf;    /* NB the above will be wrong if time_t is FP */


   case tod_epoch_l:
     /* Unix epoch/usec format */
-    (void) sprintf(CS timebuf, TIME_T_FMT "%06ld", now.tv_sec, (long) now.tv_usec );
+    (void) snprintf(CS timebuf, sizeof(timebuf), TIME_T_FMT "%06ld", now.tv_sec, (long) now.tv_usec );
     return timebuf;


   case tod_zulu:
     t = gmtime(&now.tv_sec);
-    (void) sprintf(CS timebuf, "%04u%02u%02u%02u%02u%02uZ",
+    (void) snprintf(CS timebuf, sizeof(timebuf), "%04u%02u%02u%02u%02u%02uZ",
       1900 + (uint)t->tm_year, 1 + (uint)t->tm_mon, (uint)t->tm_mday, (uint)t->tm_hour, (uint)t->tm_min,
       (uint)t->tm_sec);
     return timebuf;
@@ -91,13 +91,13 @@ switch(type)
   case tod_log_bare:          /* Format used in logging without timezone */
 #ifndef COMPILE_UTILITY
     if (LOGGING(millisec))
-      sprintf(CS timebuf, "%04u-%02u-%02u %02u:%02u:%02u.%03u",
+      snprintf(CS timebuf, sizeof(timebuf), "%04u-%02u-%02u %02u:%02u:%02u.%03u",
     1900 + (uint)t->tm_year, 1 + (uint)t->tm_mon, (uint)t->tm_mday,
     (uint)t->tm_hour, (uint)t->tm_min, (uint)t->tm_sec,
     (uint)(now.tv_usec/1000));
     else
 #endif
-      sprintf(CS timebuf, "%04u-%02u-%02u %02u:%02u:%02u",
+      snprintf(CS timebuf, sizeof(timebuf), "%04u-%02u-%02u %02u:%02u:%02u",
     1900 + (uint)t->tm_year, 1 + (uint)t->tm_mon, (uint)t->tm_mday,
     (uint)t->tm_hour, (uint)t->tm_min, (uint)t->tm_sec);


@@ -109,20 +109,20 @@ switch(type)
 #ifdef TESTING_LOG_DATESTAMP
   case tod_log_datestamp_daily:
   case tod_log_datestamp_monthly:
-    sprintf(CS timebuf, "%04u%02u%02u%02u%02u",
+    snprintf(CS timebuf, sizeof(timebuf), "%04u%02u%02u%02u%02u",
       1900 + (uint)t->tm_year, 1 + (uint)t->tm_mon, (uint)t->tm_mday,
       (uint)t->tm_hour, (uint)t->tm_min);
     break;


 #else
   case tod_log_datestamp_daily:
-    sprintf(CS timebuf, "%04u%02u%02u",
+    snprintf(CS timebuf, sizeof(timebuf), "%04u%02u%02u",
       1900 + (uint)t->tm_year, 1 + (uint)t->tm_mon, (uint)t->tm_mday);
     break;


   case tod_log_datestamp_monthly:
 #ifndef COMPILE_UTILITY
-    sprintf(CS timebuf, "%04u%02u",
+    snprintf(CS timebuf, sizeof(timebuf), "%04u%02u",
       1900 + (uint)t->tm_year, 1 + (uint)t->tm_mon);
 #endif
     break;
@@ -170,14 +170,14 @@ switch(type)
     case tod_log_zone:          /* Format used in logging with timezone */
 #ifndef COMPILE_UTILITY
       if (LOGGING(millisec))
-        (void) sprintf(CS timebuf,
+        (void) snprintf(CS timebuf, sizeof(timebuf),
           "%04u-%02u-%02u %02u:%02u:%02u.%03u %+03d%02d",
           1900 + (uint)local.tm_year, 1 + (uint)local.tm_mon, (uint)local.tm_mday,
           (uint)local.tm_hour, (uint)local.tm_min, (uint)local.tm_sec, (uint)(now.tv_usec/1000),
           diff_hour, diff_min);
       else
 #endif
-        (void) sprintf(CS timebuf,
+        (void) snprintf(CS timebuf, sizeof(timebuf),
           "%04u-%02u-%02u %02u:%02u:%02u %+03d%02d",
           1900 + (uint)local.tm_year, 1 + (uint)local.tm_mon, (uint)local.tm_mday,
           (uint)local.tm_hour, (uint)local.tm_min, (uint)local.tm_sec,
@@ -185,7 +185,7 @@ switch(type)
       break;


     case tod_zone:              /* Just the timezone offset */
-      (void) sprintf(CS timebuf, "%+03d%02d", diff_hour, diff_min);
+      (void) snprintf(CS timebuf, sizeof(timebuf), "%+03d%02d", diff_hour, diff_min);
       break;


     /* tod_mbx: format used in MBX mailboxes - subtly different to tod_full */
@@ -194,11 +194,11 @@ switch(type)
     case tod_mbx:
         {
         int len;
-        (void) sprintf(CS timebuf, "%02u-", (uint)local.tm_mday);
+        (void) snprintf(CS timebuf, sizeof(timebuf), "%02u-", (uint)local.tm_mday);
         len = Ustrlen(timebuf);
         len += Ustrftime(timebuf + len, sizeof(timebuf) - len, "%b-%Y %H:%M:%S",
           &local);
-        (void) sprintf(CS timebuf + len, " %+03d%02d", diff_hour, diff_min);
+        (void) snprintf(CS timebuf + len, sizeof(timebuf)-len, " %+03d%02d", diff_hour, diff_min);
         }
       break;
       #endif
@@ -209,11 +209,11 @@ switch(type)
     default:
         {
         int len = Ustrftime(timebuf, sizeof(timebuf), "%a, ", &local);
-        (void) sprintf(CS timebuf + len, "%02u ", (uint)local.tm_mday);
+        (void) snprintf(CS timebuf + len, sizeof(timebuf)-len, "%02u ", (uint)local.tm_mday);
         len += Ustrlen(timebuf + len);
         len += Ustrftime(timebuf + len, sizeof(timebuf) - len, "%b %Y %H:%M:%S",
           &local);
-        (void) sprintf(CS timebuf + len, " %+03d%02d", diff_hour, diff_min);
+        (void) snprintf(CS timebuf + len, sizeof(timebuf)-len, " %+03d%02d", diff_hour, diff_min);
         }
       break;
     }