diff options
author | Werner Koch <[email protected]> | 2023-06-13 08:07:07 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2023-06-13 08:07:07 +0000 |
commit | 808494b48577c2efb894a0877f59d9c4ed664f56 (patch) | |
tree | 2cbec3605802ff7e2c5d205d55b5322c91b44d12 /g10/photoid.c | |
parent | gpg: Print status line and proper diagnostics for write errors. (diff) | |
download | gnupg-808494b48577c2efb894a0877f59d9c4ed664f56.tar.gz gnupg-808494b48577c2efb894a0877f59d9c4ed664f56.zip |
gpg: Make progress work for large files on Windows.
* common/iobuf.c (iobuf_get_filelength): Change return type to
uint64_t and remove the overflow args. For Windows always use
GetFileSizeEx which is available since the long EOL-ed Windows XP.
* g10/sign.c (write_plaintext_packet): Adjust for changed
iobuf_get_filelength.
* g10/encrypt.c (encrypt_simple, encrypt_crypt): Ditto.
* g10/photoid.c (generate_photo_id): Ditto. Also add an upper limit.
* g10/filter.h (progress_filter_context_t): Change amount values to
use uint64_t.
* g10/progress.c (write_status_progress): Change accordingly.
--
GnuPG-bug-id: 6534
Diffstat (limited to 'g10/photoid.c')
-rw-r--r-- | g10/photoid.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/g10/photoid.c b/g10/photoid.c index 72e6acf7d..fc8866121 100644 --- a/g10/photoid.c +++ b/g10/photoid.c @@ -160,12 +160,11 @@ generate_photo_id (ctrl_t ctrl, PKT_public_key *pk,const char *photo_name) { PKT_user_id *uid; int error=1,i; - unsigned int len; + uint64_t len; char *filename; byte *photo=NULL; byte header[16]; IOBUF file; - int overflow; header[0]=0x10; /* little side of photo header length */ header[1]=0; /* big side of photo header length */ @@ -233,11 +232,18 @@ generate_photo_id (ctrl_t ctrl, PKT_public_key *pk,const char *photo_name) } - len=iobuf_get_filelength(file, &overflow); - if(len>6144 || overflow) + len = iobuf_get_filelength(file); + if(len>6144) { - tty_printf( _("This JPEG is really large (%d bytes) !\n"),len); - if(!cpr_get_answer_is_yes("photoid.jpeg.size", + /* We silently skip JPEGs larger than 1MiB because we have a + * 2MiB limit on the user ID packets and we need some limit + * anyway because the returned u64 is larger than the u32 or + * OpenPGP. Note that the diagnostic may print a wrong + * value if the value is really large; we don't fix this to + * avoid a string change. */ + tty_printf( _("This JPEG is really large (%d bytes) !\n"), (int)len); + if(len > 1024*1024 + || !cpr_get_answer_is_yes("photoid.jpeg.size", _("Are you sure you want to use it? (y/N) "))) { iobuf_close(file); |