Commit 6e2d81f54fe89ce6056aa2499cb376dbca8523f6

humphreyj 2019-03-01T06:45:46

Add more bytes to SMTP_DATE_MAX_SZ define to silence recent compiler warnings. The previous size was enough to contain the maximum possible size. Remove the redefinition of that size in the test header.

diff --git a/src/smtp.c b/src/smtp.c
index 85a0fee..61b9b9b 100644
--- a/src/smtp.c
+++ b/src/smtp.c
@@ -2199,7 +2199,7 @@ smtp_initiate_handshake(struct smtp *const smtp,
    Add more bytes to the 32 maximum size to silence compiler warning on the
    computed UTF offset.
  */
-#define SMTP_DATE_MAX_SZ (32 + 5)
+#define SMTP_DATE_MAX_SZ (32 + 15)
 
 /**
  * Convert the time into an RFC 2822 formatted string.
@@ -2291,7 +2291,7 @@ smtp_date_rfc_2822(char *const date){
                tm_local.tm_sec, /* 0 - 60 (leap second) */
                offset_utc);
 
-  if(rc + 1 != SMTP_DATE_MAX_SZ - 5){ /* See @ref SMTP_DATE_MAX_SZ for -5. */
+  if(rc + 1 != SMTP_DATE_MAX_SZ - 15){ /* See @ref SMTP_DATE_MAX_SZ for -5. */
     return -1;
   }
 
diff --git a/test/test.c b/test/test.c
index 7552b38..1b3d7cd 100644
--- a/test/test.c
+++ b/test/test.c
@@ -1488,7 +1488,7 @@ static void
 smtp_unit_test_date_rfc_2822(time_t t,
                              const char *const expect,
                              int expect_rc){
-  char result[SMTP_DATE_MAX_SZ];
+  char result[1000];
   int rc;
 
   g_smtp_test_time_custom_ret = 1;
diff --git a/test/test.h b/test/test.h
index b636bd0..35b48c5 100644
--- a/test/test.h
+++ b/test/test.h
@@ -47,14 +47,6 @@
 struct smtp_command;
 struct str_getdelimfd;
 
-/**
- * Maximum size of an RFC 2822 date string.
- *
- * Also defined in @ref smtp.c. Redefined here because the unit tests
- * need to use this max size when calling the @ref smtp_date_rfc_2822 function.
- */
-#define SMTP_DATE_MAX_SZ (32 + 5)
-
 int
 smtp_si_add_size_t(const size_t a,
                    const size_t b,