diff options
author | Andre Heinecke <[email protected]> | 2023-06-16 12:33:19 +0000 |
---|---|---|
committer | Andre Heinecke <[email protected]> | 2023-06-16 12:33:19 +0000 |
commit | 5811d069d3b391e9fd77c1062a2d96be41645422 (patch) | |
tree | bcf7cf9fd50d87e350298d69a9fd1d5deb4b900e | |
parent | cpp: Expose gpgme_data_set_flag through cpp API (diff) | |
download | gpgme-5811d069d3b391e9fd77c1062a2d96be41645422.tar.gz gpgme-5811d069d3b391e9fd77c1062a2d96be41645422.zip |
qt, cpp: Support larger size-hint on 32 bit builds
* NEWS: Mention this.
* lang/cpp/src/data.h, lang/cpp/src/data.cpp (Data::setSizeHint): New.
* lang/qt/src/qgpgmedecryptjob.cpp,
lang/qt/src/qgpgmedecryptverifyarchivejob.cpp,
lang/qt/src/qgpgmedecryptverifyjob.cpp,
lang/qt/src/qgpgmeencryptjob.cpp,
lang/qt/src/qgpgmesignencryptjob.cpp,
lang/qt/src/qgpgmesignjob.cpp,
lang/qt/src/qgpgmeverifydetachedjob.cpp,
lang/qt/src/qgpgmeverifyopaquejob.cpp: Set size for input IODevice.
--
This fixes the case where the old detection of the size of QIOdevice
using seek would overflow and instead explicitly uses QIODevice::size
to check for the size and pass it through as an uint64.
GnuPG-Bug-Id: T6534
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | lang/cpp/src/data.cpp | 6 | ||||
-rw-r--r-- | lang/cpp/src/data.h | 4 | ||||
-rw-r--r-- | lang/qt/src/qgpgmedecryptjob.cpp | 5 | ||||
-rw-r--r-- | lang/qt/src/qgpgmedecryptverifyarchivejob.cpp | 3 | ||||
-rw-r--r-- | lang/qt/src/qgpgmedecryptverifyjob.cpp | 5 | ||||
-rw-r--r-- | lang/qt/src/qgpgmeencryptjob.cpp | 3 | ||||
-rw-r--r-- | lang/qt/src/qgpgmesignencryptjob.cpp | 3 | ||||
-rw-r--r-- | lang/qt/src/qgpgmesignjob.cpp | 5 | ||||
-rw-r--r-- | lang/qt/src/qgpgmeverifydetachedjob.cpp | 3 | ||||
-rw-r--r-- | lang/qt/src/qgpgmeverifyopaquejob.cpp | 5 |
11 files changed, 43 insertions, 4 deletions
@@ -1,12 +1,17 @@ Noteworthy changes in version 1.21.0 (unreleased) ------------------------------------------------- + * Qt Jobs working with QIODeviceDataProvider now properly + handle input-size hints and progress for files larger. + 2^32 bytes in 32 bit builds. [T6534] + * Error::isCanceled now also returns true for error code GPG_ERR_FULLY_CANCELED. [T6510] * Interface changes relative to the 1.20.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cpp: Data::setFlag NEW. + cpp: Data::setSizeHint NEW. Noteworthy changes in version 1.20.0 (2023-04-20) ------------------------------------------------- diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp index 54d156c3..cf43b5bd 100644 --- a/lang/cpp/src/data.cpp +++ b/lang/cpp/src/data.cpp @@ -285,3 +285,9 @@ GpgME::Error GpgME::Data::setFlag(const char *name, const char *value) { return Error(gpgme_data_set_flag(d->data, name, value)); } + +GpgME::Error GpgME::Data::setSizeHint(uint64_t size) +{ + const std::string val = std::to_string(size); + return Error(gpgme_data_set_flag(d->data, "size-hint", val.c_str())); +} diff --git a/lang/cpp/src/data.h b/lang/cpp/src/data.h index ea394804..178bc309 100644 --- a/lang/cpp/src/data.h +++ b/lang/cpp/src/data.h @@ -27,6 +27,7 @@ #include "key.h" #include <sys/types.h> // for size_t, off_t +#include <cstdint> // unit64_t #include <cstdio> // FILE #include <algorithm> #include <memory> @@ -125,6 +126,9 @@ public: /** See gpgme_data_set_flag */ Error setFlag(const char *name, const char *value); + /** Set a size hint for this data e.g. for progress calculations. */ + Error setSizeHint(uint64_t size); + class Private; Private *impl() { diff --git a/lang/qt/src/qgpgmedecryptjob.cpp b/lang/qt/src/qgpgmedecryptjob.cpp index c33a4b5f..37c7ee18 100644 --- a/lang/qt/src/qgpgmedecryptjob.cpp +++ b/lang/qt/src/qgpgmedecryptjob.cpp @@ -71,7 +71,10 @@ static QGpgMEDecryptJob::result_type decrypt(Context *ctx, QThread *thread, const _detail::ToThreadMover ptMover(plainText, thread); QGpgME::QIODeviceDataProvider in(cipherText); - const Data indata(&in); + Data indata(&in); + if (!cipherText->isSequential()) { + indata.setSizeHint(cipherText->size()); + } if (!plainText) { QGpgME::QByteArrayDataProvider out; diff --git a/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp b/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp index ddbbac20..68c97f87 100644 --- a/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp +++ b/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp @@ -92,6 +92,9 @@ static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify(Context *ctx, QGpgME::QIODeviceDataProvider in{cipherText}; Data indata(&in); + if (!cipherText->isSequential()) { + indata.setSizeHint(cipherText->size()); + } Data outdata; if (!outputDirectory.isEmpty()) { diff --git a/lang/qt/src/qgpgmedecryptverifyjob.cpp b/lang/qt/src/qgpgmedecryptverifyjob.cpp index e2b3724a..256160b5 100644 --- a/lang/qt/src/qgpgmedecryptverifyjob.cpp +++ b/lang/qt/src/qgpgmedecryptverifyjob.cpp @@ -76,7 +76,10 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread const _detail::ToThreadMover ptMover(plainText, thread); QGpgME::QIODeviceDataProvider in(cipherText); - const Data indata(&in); + Data indata(&in); + if (!cipherText->isSequential()) { + indata.setSizeHint(cipherText->size()); + } if (!plainText) { QGpgME::QByteArrayDataProvider out; diff --git a/lang/qt/src/qgpgmeencryptjob.cpp b/lang/qt/src/qgpgmeencryptjob.cpp index 54066fd0..dffd3acb 100644 --- a/lang/qt/src/qgpgmeencryptjob.cpp +++ b/lang/qt/src/qgpgmeencryptjob.cpp @@ -112,6 +112,9 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, QGpgME::QIODeviceDataProvider in(plainText); Data indata(&in); + if (!plainText->isSequential()) { + indata.setSizeHint(plainText->size()); + } const auto pureFileName = QFileInfo{fileName}.fileName().toStdString(); if (!pureFileName.empty()) { diff --git a/lang/qt/src/qgpgmesignencryptjob.cpp b/lang/qt/src/qgpgmesignencryptjob.cpp index cc331ed5..e752c0bc 100644 --- a/lang/qt/src/qgpgmesignencryptjob.cpp +++ b/lang/qt/src/qgpgmesignencryptjob.cpp @@ -108,6 +108,9 @@ static QGpgMESignEncryptJob::result_type sign_encrypt(Context *ctx, QThread *thr QGpgME::QIODeviceDataProvider in(plainText); Data indata(&in); + if (!plainText->isSequential()) { + indata.setSizeHint(plainText->size()); + } const auto pureFileName = QFileInfo{fileName}.fileName().toStdString(); if (!pureFileName.empty()) { diff --git a/lang/qt/src/qgpgmesignjob.cpp b/lang/qt/src/qgpgmesignjob.cpp index e89b9457..a5e4f0f2 100644 --- a/lang/qt/src/qgpgmesignjob.cpp +++ b/lang/qt/src/qgpgmesignjob.cpp @@ -81,7 +81,10 @@ static QGpgMESignJob::result_type sign(Context *ctx, QThread *thread, const _detail::ToThreadMover sgMover(signature, thread); QGpgME::QIODeviceDataProvider in(plainText); - const Data indata(&in); + Data indata(&in); + if (!plainText->isSequential()) { + indata.setSizeHint(plainText->size()); + } ctx->clearSigningKeys(); Q_FOREACH (const Key &signer, signers) diff --git a/lang/qt/src/qgpgmeverifydetachedjob.cpp b/lang/qt/src/qgpgmeverifydetachedjob.cpp index 067366aa..52d4329b 100644 --- a/lang/qt/src/qgpgmeverifydetachedjob.cpp +++ b/lang/qt/src/qgpgmeverifydetachedjob.cpp @@ -71,6 +71,9 @@ static QGpgMEVerifyDetachedJob::result_type verify_detached(Context *ctx, QThrea QGpgME::QIODeviceDataProvider dataDP(signedData); Data data(&dataDP); + if (!signedData->isSequential()) { + data.setSizeHint(signedData->size()); + } const VerificationResult res = ctx->verifyDetachedSignature(sig, data); Error ae; diff --git a/lang/qt/src/qgpgmeverifyopaquejob.cpp b/lang/qt/src/qgpgmeverifyopaquejob.cpp index 56c0f50e..01372e07 100644 --- a/lang/qt/src/qgpgmeverifyopaquejob.cpp +++ b/lang/qt/src/qgpgmeverifyopaquejob.cpp @@ -70,7 +70,10 @@ static QGpgMEVerifyOpaqueJob::result_type verify_opaque(Context *ctx, QThread *t const _detail::ToThreadMover sdMover(signedData, thread); QGpgME::QIODeviceDataProvider in(signedData); - const Data indata(&in); + Data indata(&in); + if (!signedData->isSequential()) { + indata.setSizeHint(signedData->size()); + } if (!plainText) { QGpgME::QByteArrayDataProvider out; |