45
/* Put an upper limit on nested packets. The 32 is an arbitrary
46
value, a much lower should actually be sufficient. */
47
#define MAX_NESTING_DEPTH 32
45
50
struct kidlist_item {
46
51
struct kidlist_item *next;
87
92
int last_was_session_key;
88
93
KBNODE list; /* The current list of packets. */
90
94
IOBUF iobuf; /* Used to get the filename etc. */
91
95
int trustletter; /* Temporary usage in list_node. */
93
97
struct kidlist_item *pkenc_list; /* List of encryption packets. */
94
int any_sig_seen; /* Set to true if a signature packet has been seen. */
99
unsigned int sig_seen:1; /* Set to true if a signature packet
101
unsigned int data:1; /* Any data packet seen */
102
unsigned int uncompress_failed:1;
764
774
return proc_encryption_packets( info, a );
768
778
proc_compressed( CTX c, PACKET *pkt )
770
PKT_compressed *zd = pkt->pkt.compressed;
773
/*printf("zip: compressed data packet\n");*/
775
rc = handle_compressed( c, zd, proc_compressed_cb, c );
776
else if( c->encrypt_only )
777
rc = handle_compressed( c, zd, proc_encrypt_cb, c );
779
rc = handle_compressed( c, zd, NULL, NULL );
781
log_error("uncompressing failed: %s\n", g10_errstr(rc));
783
c->last_was_session_key = 0;
780
PKT_compressed *zd = pkt->pkt.compressed;
783
/*printf("zip: compressed data packet\n");*/
785
rc = handle_compressed (c, zd, proc_compressed_cb, c);
786
else if (c->encrypt_only)
787
rc = handle_compressed (c, zd, proc_encrypt_cb, c);
789
rc = handle_compressed (c, zd, NULL, NULL);
791
if (gpg_err_code (rc) == GPG_ERR_BAD_DATA)
793
if (!c->any.uncompress_failed)
797
for (cc=c; cc; cc = cc->anchor)
798
cc->any.uncompress_failed = 1;
799
log_error ("uncompressing failed: %s\n", g10_errstr(rc));
803
log_error("uncompressing failed: %s\n", g10_errstr(rc));
806
c->last_was_session_key = 0;
786
810
/****************
1197
1221
Using log_error is required because verify_files does not check
1198
1222
error codes for each file but we want to terminate the process
1199
1223
with an error. */
1200
if (!rc && !c->any_sig_seen)
1224
if (!rc && !c->any.sig_seen)
1202
1226
write_status_text (STATUS_NODATA, "4");
1203
1227
log_error (_("no signature found\n"));
1207
1231
/* Propagate the signature seen flag upward. Do this only on
1208
1232
success so that we won't issue the nodata status several
1210
if (!rc && c->anchor && c->any_sig_seen)
1211
c->anchor->any_sig_seen = 1;
1234
if (!rc && c->anchor && c->any.sig_seen)
1235
c->anchor->any.sig_seen = 1;
1234
1258
Using log_error is required because verify_files does not check
1235
1259
error codes for each file but we want to terminate the process
1236
1260
with an error. */
1237
if (!rc && !c->any_sig_seen)
1261
if (!rc && !c->any.sig_seen)
1239
1263
write_status_text (STATUS_NODATA, "4");
1240
1264
log_error (_("no signature found\n"));
1244
1268
/* Propagate the signature seen flag upward. Do this only on success
1245
1269
so that we won't issue the nodata status several times. */
1246
if (!rc && c->anchor && c->any_sig_seen)
1247
c->anchor->any_sig_seen = 1;
1270
if (!rc && c->anchor && c->any.sig_seen)
1271
c->anchor->any.sig_seen = 1;
1293
check_nesting (CTX c)
1297
for (level=0; c; c = c->anchor)
1300
if (level > MAX_NESTING_DEPTH)
1302
log_error ("input data with too deeply nested packets\n");
1303
write_status_text (STATUS_UNEXPECTED, "1");
1304
return GPG_ERR_BAD_DATA;
1269
1311
do_proc_packets( CTX c, IOBUF a )
1271
PACKET *pkt = xmalloc( sizeof *pkt );
1318
rc = check_nesting (c);
1322
pkt = xmalloc( sizeof *pkt );
1277
1324
init_packet(pkt);
1278
1325
while( (rc=parse_packet(a, pkt)) != -1 ) {
1293
1340
case PKT_SYMKEY_ENC: proc_symkey_enc( c, pkt ); break;
1294
1341
case PKT_ENCRYPTED:
1295
1342
case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break;
1296
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
1343
case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break;
1297
1344
default: newpkt = 0; break;
1312
1359
case PKT_SIGNATURE: newpkt = add_signature( c, pkt ); break;
1313
1360
case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break;
1314
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
1361
case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break;
1315
1362
case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break;
1316
1363
case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break;
1317
1364
default: newpkt = 0; break;
1331
1378
case PKT_ENCRYPTED:
1332
1379
case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break;
1333
1380
case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break;
1334
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
1381
case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break;
1335
1382
case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break;
1336
1383
case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break;
1337
1384
default: newpkt = 0; break;
1356
1403
case PKT_ENCRYPTED:
1357
1404
case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break;
1358
1405
case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break;
1359
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
1406
case PKT_COMPRESSED: rc = proc_compressed( c, pkt ); break;
1360
1407
case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break;
1361
1408
case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break;
1362
1409
case PKT_RING_TRUST: newpkt = add_ring_trust( c, pkt ); break;
1363
1410
default: newpkt = 0; break;
1366
1417
/* This is a very ugly construct and frankly, I don't remember why
1367
1418
* I used it. Adding the MDC check here is a hack.
1368
1419
* The right solution is to initiate another context for encrypted
2105
2156
if( sig->sig_class != 0x00 && sig->sig_class != 0x01 )
2106
2157
log_info(_("standalone signature of class 0x%02x\n"),
2107
2158
sig->sig_class);
2108
else if( !c->have_data ) {
2159
else if( !c->any.data ) {
2109
2160
/* detached signature */
2110
2161
free_md_filter_context( &c->mfx );
2111
2162
if (gcry_md_open (&c->mfx.md, sig->digest_algo, 0))