]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added check for gnutls_db_check_entry_time().
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 27 Jan 2014 15:04:02 +0000 (16:04 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 28 Jan 2014 10:55:08 +0000 (11:55 +0100)
tests/resume.c

index c238a8667e4e555a6f202374f95b0f5e951f2193..3579e8868187c0767bd6ce4bcbef62f2eb0b6767 100644 (file)
@@ -469,6 +469,8 @@ static void wrap_db_deinit(void)
 static int
 wrap_db_store(void *dbf, gnutls_datum_t key, gnutls_datum_t data)
 {
+       time_t t, now = time(0);
+
        if (debug) {
                unsigned int i;
                fprintf(stderr, "resume db storing (%d-%d): ", key.size,
@@ -484,6 +486,13 @@ wrap_db_store(void *dbf, gnutls_datum_t key, gnutls_datum_t data)
                fprintf(stderr, "\n");
        }
 
+       /* check the correctness of gnutls_db_check_entry_time() */
+       t = gnutls_db_check_entry_time(&data);
+       if (t < now - 10 || t > now + 10) {
+               fail("Time returned by gnutls_db_check_entry_time is bogus\n");
+               exit(1);
+       }
+
        if (cache_db == NULL)
                return -1;