mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Merge branch 'STABLE-BRANCH-2-4' into master
This commit is contained in:
commit
334f5d95c8
89 changed files with 3260 additions and 1400 deletions
|
@ -991,12 +991,20 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
|
|||
if (nbytes == (size_t)(-1)
|
||||
&& (iobuf_error (out) || iobuf_error (pt->buf)))
|
||||
return iobuf_error (out)? iobuf_error (out):iobuf_error (pt->buf);
|
||||
/* Always get the error to catch write errors because
|
||||
* iobuf_copy does not reliable return (-1) in that case. */
|
||||
rc = iobuf_error (out);
|
||||
if(ctb_new_format_p (ctb) && !pt->len)
|
||||
/* Turn off partial body length mode. */
|
||||
iobuf_set_partial_body_length_mode (out, 0);
|
||||
if( pt->len && nbytes != pt->len )
|
||||
log_error("do_plaintext(): wrote %lu bytes but expected %lu bytes\n",
|
||||
(ulong)nbytes, (ulong)pt->len );
|
||||
if (pt->len && nbytes != pt->len)
|
||||
{
|
||||
log_error ("do_plaintext(): wrote %lu bytes"
|
||||
" but expected %lu bytes\n",
|
||||
(ulong)nbytes, (ulong)pt->len );
|
||||
if (!rc) /* Just in case no error was set */
|
||||
rc = gpg_error (GPG_ERR_EIO);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
|
|
@ -559,12 +559,12 @@ encrypt_simple (const char *filename, int mode, int use_seskey)
|
|||
|
||||
if ( !iobuf_is_pipe_filename (filename) && *filename && !opt.textmode )
|
||||
{
|
||||
off_t tmpsize;
|
||||
int overflow;
|
||||
uint64_t tmpsize;
|
||||
|
||||
if ( !(tmpsize = iobuf_get_filelength(inp, &overflow))
|
||||
&& !overflow && opt.verbose)
|
||||
tmpsize = iobuf_get_filelength(inp);
|
||||
if (!tmpsize && opt.verbose)
|
||||
log_info(_("WARNING: '%s' is an empty file\n"), filename );
|
||||
|
||||
/* We can't encode the length of very large files because
|
||||
OpenPGP uses only 32 bit for file sizes. So if the
|
||||
size of a file is larger than 2^32 minus some bytes for
|
||||
|
@ -903,11 +903,10 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
|
|||
if (filename && *filename
|
||||
&& !iobuf_is_pipe_filename (filename) && !opt.textmode )
|
||||
{
|
||||
off_t tmpsize;
|
||||
int overflow;
|
||||
uint64_t tmpsize;
|
||||
|
||||
if ( !(tmpsize = iobuf_get_filelength(inp, &overflow))
|
||||
&& !overflow && opt.verbose)
|
||||
tmpsize = iobuf_get_filelength (inp);
|
||||
if (!tmpsize && opt.verbose)
|
||||
log_info(_("WARNING: '%s' is an empty file\n"), filename );
|
||||
/* We can't encode the length of very large files because
|
||||
OpenPGP uses only 32 bit for file sizes. So if the size
|
||||
|
|
|
@ -155,9 +155,9 @@ typedef struct {
|
|||
typedef struct {
|
||||
char *what; /* description */
|
||||
u32 last_time; /* last time reported */
|
||||
unsigned long last; /* last amount reported */
|
||||
unsigned long offset; /* current amount */
|
||||
unsigned long total; /* total amount */
|
||||
uint64_t last; /* last amount reported */
|
||||
uint64_t offset; /* current amount */
|
||||
uint64_t total; /* total amount */
|
||||
int refcount;
|
||||
} progress_filter_context_t;
|
||||
|
||||
|
|
15
g10/gpg.c
15
g10/gpg.c
|
@ -259,6 +259,7 @@ enum cmd_and_opt_values
|
|||
oCipherAlgo,
|
||||
oDigestAlgo,
|
||||
oCertDigestAlgo,
|
||||
oNoCompress,
|
||||
oCompressAlgo,
|
||||
oCompressLevel,
|
||||
oBZ2CompressLevel,
|
||||
|
@ -697,6 +698,7 @@ static gpgrt_opt_t opts[] = {
|
|||
ARGPARSE_s_n (oLockOnce, "lock-once", "@"),
|
||||
ARGPARSE_s_n (oLockMultiple, "lock-multiple", "@"),
|
||||
ARGPARSE_s_n (oLockNever, "lock-never", "@"),
|
||||
ARGPARSE_s_n (oNoCompress, "no-compress", "@"),
|
||||
ARGPARSE_s_s (oCompressAlgo,"compress-algo", "@"),
|
||||
ARGPARSE_s_s (oCompressAlgo, "compression-algo", "@"), /* Alias */
|
||||
ARGPARSE_s_n (oBZ2DecompressLowmem, "bzip2-decompress-lowmem", "@"),
|
||||
|
@ -3238,6 +3240,11 @@ main (int argc, char **argv)
|
|||
opt.compress_level = opt.bz2_compress_level = pargs.r.ret_int;
|
||||
opt.explicit_compress_option = 1;
|
||||
break;
|
||||
case oNoCompress:
|
||||
/* --no-compress is the same as -z0 */
|
||||
opt.compress_level = opt.bz2_compress_level = 0;
|
||||
opt.explicit_compress_option = 1;
|
||||
break;
|
||||
case oCompressLevel: opt.compress_level = pargs.r.ret_int; break;
|
||||
case oBZ2CompressLevel: opt.bz2_compress_level = pargs.r.ret_int; break;
|
||||
case oBZ2DecompressLowmem: opt.bz2_decompress_lowmem=1; break;
|
||||
|
@ -3499,7 +3506,13 @@ main (int argc, char **argv)
|
|||
case oAllowFreeformUID: opt.allow_freeform_uid = 1; break;
|
||||
case oNoAllowFreeformUID: opt.allow_freeform_uid = 0; break;
|
||||
case oNoLiteral: opt.no_literal = 1; break;
|
||||
case oSetFilesize: opt.set_filesize = pargs.r.ret_ulong; break;
|
||||
|
||||
case oSetFilesize:
|
||||
/* There are restricts on the value (e.g. < 2^32); you
|
||||
* need to check the entire code to understand this. */
|
||||
opt.set_filesize = pargs.r.ret_ulong;
|
||||
break;
|
||||
|
||||
case oFastListMode: opt.fast_list_mode = 1; break;
|
||||
case oFixedListMode: /* Dummy */ break;
|
||||
case oLegacyListMode: opt.legacy_list_mode = 1; break;
|
||||
|
|
14
g10/import.c
14
g10/import.c
|
@ -1564,6 +1564,20 @@ impex_filter_getval (void *cookie, const char *propname)
|
|||
{
|
||||
result = dateonlystr_from_pk (pk);
|
||||
}
|
||||
else if (!strcmp (propname, "key_expires"))
|
||||
{
|
||||
snprintf (numbuf, sizeof numbuf, "%lu", (ulong)pk->expiredate);
|
||||
result = numbuf;
|
||||
}
|
||||
else if (!strcmp (propname, "key_expires_d"))
|
||||
{
|
||||
static char exdatestr[MK_DATESTR_SIZE];
|
||||
|
||||
if (pk->expiredate)
|
||||
result = mk_datestr (exdatestr, sizeof exdatestr, pk->expiredate);
|
||||
else
|
||||
result = "";
|
||||
}
|
||||
else if (!strcmp (propname, "expired"))
|
||||
{
|
||||
result = pk->has_expired? "1":"0";
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
/* When generating keys using the streamlined key generation dialog,
|
||||
use this as a default expiration interval. */
|
||||
const char *default_expiration_interval = "2y";
|
||||
const char *default_expiration_interval = "3y";
|
||||
|
||||
/* Flag bits used during key generation. */
|
||||
#define KEYGEN_FLAG_NO_PROTECTION 1
|
||||
|
|
|
@ -164,12 +164,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 */
|
||||
|
@ -237,11 +236,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);
|
||||
|
|
|
@ -72,13 +72,11 @@ release_progress_context (progress_filter_context_t *pfx)
|
|||
|
||||
|
||||
static void
|
||||
write_status_progress (const char *what,
|
||||
unsigned long current, unsigned long total_arg)
|
||||
write_status_progress (const char *what, uint64_t current, uint64_t total)
|
||||
{
|
||||
char buffer[60];
|
||||
char units[] = "BKMGTPEZY?";
|
||||
int unitidx = 0;
|
||||
uint64_t total = total_arg;
|
||||
|
||||
/* Although we use an unsigned long for the values, 32 bit
|
||||
* applications using GPGME will use an "int" and thus are limited
|
||||
|
@ -91,7 +89,10 @@ write_status_progress (const char *what,
|
|||
* to display how many percent of the operation has been done and
|
||||
* thus scaling CURRENT and TOTAL down before they get to large,
|
||||
* should not have a noticeable effect except for rounding
|
||||
* imprecision. */
|
||||
* imprecision.
|
||||
* Update 2023-06-13: We now use uint64_t but to keep the API stable
|
||||
* we still do the scaling.
|
||||
*/
|
||||
|
||||
if (!total && opt.input_size_hint)
|
||||
total = opt.input_size_hint;
|
||||
|
@ -121,7 +122,7 @@ write_status_progress (const char *what,
|
|||
unitidx = 9;
|
||||
|
||||
snprintf (buffer, sizeof buffer, "%.20s ? %lu %lu %c%s",
|
||||
what? what : "?", current, (unsigned long)total,
|
||||
what? what : "?", (unsigned long)current, (unsigned long)total,
|
||||
units[unitidx],
|
||||
unitidx? "iB" : "");
|
||||
write_status_text (STATUS_PROGRESS, buffer);
|
||||
|
@ -181,7 +182,7 @@ progress_filter (void *opaque, int control,
|
|||
void
|
||||
handle_progress (progress_filter_context_t *pfx, IOBUF inp, const char *name)
|
||||
{
|
||||
off_t filesize = 0;
|
||||
uint64_t filesize = 0;
|
||||
|
||||
if (!pfx)
|
||||
return;
|
||||
|
@ -190,7 +191,7 @@ handle_progress (progress_filter_context_t *pfx, IOBUF inp, const char *name)
|
|||
log_assert (is_status_enabled ());
|
||||
|
||||
if ( !iobuf_is_pipe_filename (name) && *name )
|
||||
filesize = iobuf_get_filelength (inp, NULL);
|
||||
filesize = iobuf_get_filelength (inp);
|
||||
else if (opt.set_filesize)
|
||||
filesize = opt.set_filesize;
|
||||
|
||||
|
|
|
@ -823,11 +823,10 @@ write_plaintext_packet (iobuf_t out, iobuf_t inp,
|
|||
/* Try to calculate the length of the data. */
|
||||
if ( !iobuf_is_pipe_filename (fname) && *fname)
|
||||
{
|
||||
off_t tmpsize;
|
||||
int overflow;
|
||||
uint64_t tmpsize;
|
||||
|
||||
if (!(tmpsize = iobuf_get_filelength (inp, &overflow))
|
||||
&& !overflow && opt.verbose)
|
||||
tmpsize = iobuf_get_filelength (inp);
|
||||
if (!tmpsize && opt.verbose)
|
||||
log_info (_("WARNING: '%s' is an empty file\n"), fname);
|
||||
|
||||
/* We can't encode the length of very large files because
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue