]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
certtool: print information on time_t restrictions on failure
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 1 Jul 2018 09:24:16 +0000 (11:24 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 2 Jul 2018 10:49:44 +0000 (12:49 +0200)
This informs the user of the tool why dates after 2038 cannot
be expressed on systems with a 32-bit time_t.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
src/certtool-cfg.c

index b4894e63a641362a3b1d00d30b4b79b8385187fe..1836fe85a1305f188fbb9a78e4ae992e79b1250b 100644 (file)
@@ -68,6 +68,10 @@ extern int ask_pass;
 #define MAX_ENTRIES 128
 #define MAX_POLICIES 8
 
+#define PRINT_TIME_T_ERROR \
+       if (sizeof(time_t) < 8) \
+               fprintf(stderr, "This system expresses time with a 32-bit time_t; that prevents dates after 2038 to be expressed by GnuTLS.\n")
+
 enum option_types { OPTION_NUMERIC, OPTION_STRING, OPTION_BOOLEAN, OPTION_MULTI_LINE };
 
 struct cfg_options {
@@ -1693,6 +1697,7 @@ time_t get_date(const char* date)
        struct timespec r;
 
        if (date==NULL || parse_datetime(&r, date, NULL) == 0) {
+               PRINT_TIME_T_ERROR;
                fprintf(stderr, "Cannot parse date: %s\n", date);
                exit(1);
        }
@@ -1754,6 +1759,7 @@ time_t now = time(NULL);
 
        return secs;
  overflow:
+       PRINT_TIME_T_ERROR;
        fprintf(stderr, "Overflow while parsing days\n");
        exit(1);
 }