diff options
author | Ingo Klöcker <[email protected]> | 2022-06-10 09:54:03 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2022-06-10 09:54:03 +0000 |
commit | 7870fdbfeff47755138136dbd6648b18f6b4fc76 (patch) | |
tree | 9f0c26667a61b7961ad089e26a1871df7ffac912 /lang/qt/src | |
parent | Revert "tests: Avoid problems with local time across a day boundary." (diff) | |
download | gpgme-7870fdbfeff47755138136dbd6648b18f6b4fc76.tar.gz gpgme-7870fdbfeff47755138136dbd6648b18f6b4fc76.zip |
qt: Prevent u32 overflow when calculating expiration date
* lang/qt/src/qgpgmesignkeyjob.cpp (sign_key): Change maxAllowedDate to
2106-02-05. Change log-level from warning to debug.
* lang/qt/tests/t-various.cpp (TestVarious::testSignKeyWithExpiration):
Remove check for warning. Adapt assertion.
--
Capping the expiration date at 2106-02-05 prevents a u32 overflow when
adding the number of days until the maximal date to the current time.
GnuPG-bug-id: 5991
Diffstat (limited to 'lang/qt/src')
-rw-r--r-- | lang/qt/src/qgpgmesignkeyjob.cpp | 6 | ||||
-rw-r--r-- | lang/qt/src/signkeyjob.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lang/qt/src/qgpgmesignkeyjob.cpp b/lang/qt/src/qgpgmesignkeyjob.cpp index 5036a9b9..506d64a1 100644 --- a/lang/qt/src/qgpgmesignkeyjob.cpp +++ b/lang/qt/src/qgpgmesignkeyjob.cpp @@ -127,11 +127,11 @@ static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, cons if (expirationDate.isValid()) { // on 2106-02-07, the Unix time will reach 0xFFFFFFFF; since gpg uses uint32 internally - // for the expiration date clip it at 2106-02-06 - static const QDate maxAllowedDate{2106, 2, 6}; + // for the expiration date clip it at 2106-02-05 to avoid problems with negative time zones + static const QDate maxAllowedDate{2106, 2, 5}; const auto clippedExpirationDate = expirationDate <= maxAllowedDate ? expirationDate : maxAllowedDate; if (clippedExpirationDate != expirationDate) { - qCWarning(QGPGME_LOG) << "Expiration of certification has been changed to" << clippedExpirationDate; + qCDebug(QGPGME_LOG) << "Expiration of certification has been changed to" << clippedExpirationDate; } // use the "days from now" format to specify the expiration date of the certification; // this format is the most appropriate regardless of the local timezone diff --git a/lang/qt/src/signkeyjob.h b/lang/qt/src/signkeyjob.h index f4b3ed8f..d0e90c22 100644 --- a/lang/qt/src/signkeyjob.h +++ b/lang/qt/src/signkeyjob.h @@ -149,7 +149,7 @@ public: * Sets the expiration date of the key signature to @a expiration. By default, * key signatures do not expire. * - * Note: Expiration dates after 2106-02-06 will be set to 2106-02-06. + * Note: Expiration dates after 2106-02-05 will be set to 2106-02-05. * * Not pure virtual for ABI compatibility. **/ |