1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

* getkey.c (merge_selfsigs_main): Make sure the revocation key list starts

clean as this function may be called more than once (e.g. from functions
in --edit).

* g10.c, encode.c (encode_crypt), sign.c (sign_file,
sign_symencrypt_file): Make --compress-algo work like the documentation
says.  It should be like --cipher-algo and --digest-algo in that it can
override the preferences calculation and impose the setting the user
wants.  No --compress-algo setting allows the usual preferences
calculation to take place.

* main.h, compress.c (compress_filter): use new DEFAULT_COMPRESS_ALGO
define, and add a sanity check for compress algo value.
This commit is contained in:
David Shaw 2002-05-09 19:57:08 +00:00
parent 4cb36096ec
commit 0c3ac11549
7 changed files with 85 additions and 44 deletions

View file

@ -596,7 +596,6 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
SK_LIST sk_rover = NULL;
int multifile = 0;
int old_style = opt.rfc1991;
int compr_algo = -1; /* unknown */
u32 timestamp=0,duration=0;
memset( &afx, 0, sizeof afx);
@ -633,12 +632,8 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
opt.pgp2=0;
}
if( encryptflag ) {
if( (rc=build_pk_list( remusr, &pk_list, PUBKEY_USAGE_ENC )) )
goto leave;
if( !old_style )
compr_algo = select_algo_from_prefs( pk_list, PREFTYPE_ZIP );
}
if(encryptflag && (rc=build_pk_list( remusr, &pk_list, PUBKEY_USAGE_ENC )))
goto leave;
/* prepare iobufs */
if( multifile ) /* have list of filenames */
@ -687,17 +682,31 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
iobuf_push_filter( out, encrypt_filter, &efx );
}
if( opt.compress && !outfile && ( !detached || opt.compress_sigs) ) {
if( !compr_algo )
; /* don't use compression */
else {
if( old_style
|| compr_algo == 1
|| (compr_algo == -1 && !encryptflag) )
zfx.algo = 1; /* use the non optional algorithm */
if( opt.compress && !outfile && ( !detached || opt.compress_sigs) )
{
int compr_algo=opt.def_compress_algo;
/* If not forced by user */
if(compr_algo==-1)
{
/* If we're not encrypting, then select_algo_from_prefs
will fail and we'll end up with the default. If we are
encrypting, select_algo_from_prefs cannot fail since
there is an assumed preference for uncompressed data.
Still, if it did fail, we'll also end up with the
default. */
if((compr_algo=select_algo_from_prefs( pk_list, PREFTYPE_ZIP))==-1)
compr_algo=DEFAULT_COMPRESS_ALGO;
}
/* algo 0 means no compression */
if( compr_algo )
{
zfx.algo = compr_algo;
iobuf_push_filter( out, compress_filter, &zfx );
}
}
}
}
/* Write the one-pass signature packets if needed */
if (!detached && !opt.rfc1991) {
@ -925,7 +934,6 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
SK_LIST sk_list = NULL;
SK_LIST sk_rover = NULL;
int old_style = opt.rfc1991;
int compr_algo = -1; /* unknown */
int algo;
u32 timestamp=0,duration=0;
@ -1011,15 +1019,20 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
iobuf_push_filter( out, cipher_filter, &cfx );
/* Push the Zip filter */
if (opt.compress) {
if (!compr_algo)
; /* don't use compression */
else {
if( old_style || compr_algo == 1 )
zfx.algo = 1; /* use the non optional algorithm */
if (opt.compress)
{
int compr_algo=opt.def_compress_algo;
/* Default */
if(compr_algo==-1)
compr_algo=DEFAULT_COMPRESS_ALGO;
if (compr_algo)
{
zfx.algo = compr_algo;
iobuf_push_filter( out, compress_filter, &zfx );
}
}
}
}
/* Write the one-pass signature packets */
/*(current filters: zip - encrypt - armor)*/