Applying Ingo's patch: Makes signatureCertificateDaysLeftToExpiry() and receiverCerti...
authorKarl-Heinz Zimmer <khz@kde.org>
Sun, 29 Sep 2002 21:14:16 +0000 (21:14 +0000)
committerKarl-Heinz Zimmer <khz@kde.org>
Sun, 29 Sep 2002 21:14:16 +0000 (21:14 +0000)
trunk/gpgmeplug/gpgmeplug.c

index 6e17c554891a4a01aa20da7c839bbaaf7d97e681..03d3dbe580e5cfc4d1e4a674dccde9f7c56cad7b 100644 (file)
@@ -557,13 +557,15 @@ int signatureCertificateDaysLeftToExpiry( const char* certificate )
     if ( GPGME_No_Error == err ) {
       time_t expire_time = gpgme_key_get_ulong_attr(
                              rKey, GPGME_ATTR_EXPIRE, NULL, 0 );
-      time_t cur_time = time (NULL);
-      if( cur_time > expire_time ) {
-        daysLeft = days_from_seconds(cur_time - expire_time);
-        daysLeft *= -1;
+      if ( 0 != expire_time ) {
+        time_t cur_time = time (NULL);
+        if( cur_time > expire_time ) {
+          daysLeft = days_from_seconds(cur_time - expire_time);
+          daysLeft *= -1;
+        }
+        else
+          daysLeft = days_from_seconds(expire_time - cur_time);
       }
-      else
-        daysLeft = days_from_seconds(expire_time - cur_time);
       gpgme_key_release( rKey );
     }
   }
@@ -847,13 +849,15 @@ int receiverCertificateDaysLeftToExpiry( const char* certificate )
     if ( GPGME_No_Error == err ) {
       time_t expire_time = gpgme_key_get_ulong_attr(
                              rKey,GPGME_ATTR_EXPIRE, NULL, 0 );
-      time_t cur_time = time (NULL);
-      if( cur_time > expire_time ) {
-        daysLeft = days_from_seconds(cur_time - expire_time);
-        daysLeft *= -1;
+      if ( 0 != expire_time ) {
+        time_t cur_time = time (NULL);
+        if( cur_time > expire_time ) {
+          daysLeft = days_from_seconds(cur_time - expire_time);
+          daysLeft *= -1;
+        }
+        else
+          daysLeft = days_from_seconds(expire_time - cur_time);
       }
-      else
-        daysLeft = days_from_seconds(expire_time - cur_time);
       gpgme_key_release( rKey );
     }
   }