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
This commit is contained in:
parent
cbcea4a09b
commit
5811d069d3
5
NEWS
5
NEWS
@ -1,12 +1,17 @@
|
|||||||
Noteworthy changes in version 1.21.0 (unreleased)
|
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
|
* Error::isCanceled now also returns true for error code
|
||||||
GPG_ERR_FULLY_CANCELED. [T6510]
|
GPG_ERR_FULLY_CANCELED. [T6510]
|
||||||
|
|
||||||
* Interface changes relative to the 1.20.0 release:
|
* Interface changes relative to the 1.20.0 release:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
cpp: Data::setFlag NEW.
|
cpp: Data::setFlag NEW.
|
||||||
|
cpp: Data::setSizeHint NEW.
|
||||||
|
|
||||||
Noteworthy changes in version 1.20.0 (2023-04-20)
|
Noteworthy changes in version 1.20.0 (2023-04-20)
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
@ -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));
|
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()));
|
||||||
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
|
||||||
#include <sys/types.h> // for size_t, off_t
|
#include <sys/types.h> // for size_t, off_t
|
||||||
|
#include <cstdint> // unit64_t
|
||||||
#include <cstdio> // FILE
|
#include <cstdio> // FILE
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -125,6 +126,9 @@ public:
|
|||||||
/** See gpgme_data_set_flag */
|
/** See gpgme_data_set_flag */
|
||||||
Error setFlag(const char *name, const char *value);
|
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;
|
class Private;
|
||||||
Private *impl()
|
Private *impl()
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,10 @@ static QGpgMEDecryptJob::result_type decrypt(Context *ctx, QThread *thread,
|
|||||||
const _detail::ToThreadMover ptMover(plainText, thread);
|
const _detail::ToThreadMover ptMover(plainText, thread);
|
||||||
|
|
||||||
QGpgME::QIODeviceDataProvider in(cipherText);
|
QGpgME::QIODeviceDataProvider in(cipherText);
|
||||||
const Data indata(&in);
|
Data indata(&in);
|
||||||
|
if (!cipherText->isSequential()) {
|
||||||
|
indata.setSizeHint(cipherText->size());
|
||||||
|
}
|
||||||
|
|
||||||
if (!plainText) {
|
if (!plainText) {
|
||||||
QGpgME::QByteArrayDataProvider out;
|
QGpgME::QByteArrayDataProvider out;
|
||||||
|
@ -92,6 +92,9 @@ static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify(Context *ctx,
|
|||||||
|
|
||||||
QGpgME::QIODeviceDataProvider in{cipherText};
|
QGpgME::QIODeviceDataProvider in{cipherText};
|
||||||
Data indata(&in);
|
Data indata(&in);
|
||||||
|
if (!cipherText->isSequential()) {
|
||||||
|
indata.setSizeHint(cipherText->size());
|
||||||
|
}
|
||||||
|
|
||||||
Data outdata;
|
Data outdata;
|
||||||
if (!outputDirectory.isEmpty()) {
|
if (!outputDirectory.isEmpty()) {
|
||||||
|
@ -76,7 +76,10 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread
|
|||||||
const _detail::ToThreadMover ptMover(plainText, thread);
|
const _detail::ToThreadMover ptMover(plainText, thread);
|
||||||
|
|
||||||
QGpgME::QIODeviceDataProvider in(cipherText);
|
QGpgME::QIODeviceDataProvider in(cipherText);
|
||||||
const Data indata(&in);
|
Data indata(&in);
|
||||||
|
if (!cipherText->isSequential()) {
|
||||||
|
indata.setSizeHint(cipherText->size());
|
||||||
|
}
|
||||||
|
|
||||||
if (!plainText) {
|
if (!plainText) {
|
||||||
QGpgME::QByteArrayDataProvider out;
|
QGpgME::QByteArrayDataProvider out;
|
||||||
|
@ -112,6 +112,9 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread,
|
|||||||
|
|
||||||
QGpgME::QIODeviceDataProvider in(plainText);
|
QGpgME::QIODeviceDataProvider in(plainText);
|
||||||
Data indata(&in);
|
Data indata(&in);
|
||||||
|
if (!plainText->isSequential()) {
|
||||||
|
indata.setSizeHint(plainText->size());
|
||||||
|
}
|
||||||
|
|
||||||
const auto pureFileName = QFileInfo{fileName}.fileName().toStdString();
|
const auto pureFileName = QFileInfo{fileName}.fileName().toStdString();
|
||||||
if (!pureFileName.empty()) {
|
if (!pureFileName.empty()) {
|
||||||
|
@ -108,6 +108,9 @@ static QGpgMESignEncryptJob::result_type sign_encrypt(Context *ctx, QThread *thr
|
|||||||
|
|
||||||
QGpgME::QIODeviceDataProvider in(plainText);
|
QGpgME::QIODeviceDataProvider in(plainText);
|
||||||
Data indata(&in);
|
Data indata(&in);
|
||||||
|
if (!plainText->isSequential()) {
|
||||||
|
indata.setSizeHint(plainText->size());
|
||||||
|
}
|
||||||
|
|
||||||
const auto pureFileName = QFileInfo{fileName}.fileName().toStdString();
|
const auto pureFileName = QFileInfo{fileName}.fileName().toStdString();
|
||||||
if (!pureFileName.empty()) {
|
if (!pureFileName.empty()) {
|
||||||
|
@ -81,7 +81,10 @@ static QGpgMESignJob::result_type sign(Context *ctx, QThread *thread,
|
|||||||
const _detail::ToThreadMover sgMover(signature, thread);
|
const _detail::ToThreadMover sgMover(signature, thread);
|
||||||
|
|
||||||
QGpgME::QIODeviceDataProvider in(plainText);
|
QGpgME::QIODeviceDataProvider in(plainText);
|
||||||
const Data indata(&in);
|
Data indata(&in);
|
||||||
|
if (!plainText->isSequential()) {
|
||||||
|
indata.setSizeHint(plainText->size());
|
||||||
|
}
|
||||||
|
|
||||||
ctx->clearSigningKeys();
|
ctx->clearSigningKeys();
|
||||||
Q_FOREACH (const Key &signer, signers)
|
Q_FOREACH (const Key &signer, signers)
|
||||||
|
@ -71,6 +71,9 @@ static QGpgMEVerifyDetachedJob::result_type verify_detached(Context *ctx, QThrea
|
|||||||
|
|
||||||
QGpgME::QIODeviceDataProvider dataDP(signedData);
|
QGpgME::QIODeviceDataProvider dataDP(signedData);
|
||||||
Data data(&dataDP);
|
Data data(&dataDP);
|
||||||
|
if (!signedData->isSequential()) {
|
||||||
|
data.setSizeHint(signedData->size());
|
||||||
|
}
|
||||||
|
|
||||||
const VerificationResult res = ctx->verifyDetachedSignature(sig, data);
|
const VerificationResult res = ctx->verifyDetachedSignature(sig, data);
|
||||||
Error ae;
|
Error ae;
|
||||||
|
@ -70,7 +70,10 @@ static QGpgMEVerifyOpaqueJob::result_type verify_opaque(Context *ctx, QThread *t
|
|||||||
const _detail::ToThreadMover sdMover(signedData, thread);
|
const _detail::ToThreadMover sdMover(signedData, thread);
|
||||||
|
|
||||||
QGpgME::QIODeviceDataProvider in(signedData);
|
QGpgME::QIODeviceDataProvider in(signedData);
|
||||||
const Data indata(&in);
|
Data indata(&in);
|
||||||
|
if (!signedData->isSequential()) {
|
||||||
|
indata.setSizeHint(signedData->size());
|
||||||
|
}
|
||||||
|
|
||||||
if (!plainText) {
|
if (!plainText) {
|
||||||
QGpgME::QByteArrayDataProvider out;
|
QGpgME::QByteArrayDataProvider out;
|
||||||
|
Loading…
Reference in New Issue
Block a user