Changeset View
Changeset View
Standalone View
Standalone View
g10/parse-packet.c
Show First 20 Lines • Show All 732 Lines • ▼ Show 20 Lines | pktlen = buf32_to_ulong (value); | ||||
{ | { | ||||
switch (pkttype) | switch (pkttype) | ||||
{ | { | ||||
case PKT_PLAINTEXT: | case PKT_PLAINTEXT: | ||||
case PKT_ENCRYPTED: | case PKT_ENCRYPTED: | ||||
case PKT_ENCRYPTED_MDC: | case PKT_ENCRYPTED_MDC: | ||||
case PKT_ENCRYPTED_AEAD: | case PKT_ENCRYPTED_AEAD: | ||||
case PKT_COMPRESSED: | case PKT_COMPRESSED: | ||||
if (ctx->sigs_only) | |||||
{ | |||||
log_error (_("partial length packet of type %d in detached" | |||||
" signature\n"), pkttype); | |||||
rc = gpg_error (GPG_ERR_UNEXPECTED); | |||||
goto leave; | |||||
} | |||||
if (onlykeypkts) | |||||
{ | |||||
log_error (_("partial length packet of type %d in keyring\n"), | |||||
pkttype); | |||||
rc = gpg_error (GPG_ERR_UNEXPECTED); | |||||
goto leave; | |||||
} | |||||
iobuf_set_partial_body_length_mode (inp, c & 0xff); | iobuf_set_partial_body_length_mode (inp, c & 0xff); | ||||
pktlen = 0; /* To indicate partial length. */ | pktlen = 0; /* To indicate partial length. */ | ||||
partial = 1; | partial = 1; | ||||
break; | break; | ||||
default: | default: | ||||
log_error ("%s: partial length invalid for" | log_error ("%s: partial length invalid for" | ||||
" packet type %d\n", iobuf_where (inp), pkttype); | " packet type %d\n", iobuf_where (inp), pkttype); | ||||
Show All 21 Lines | tag. */ | ||||
if (pkttype != PKT_ENCRYPTED && pkttype != PKT_PLAINTEXT | if (pkttype != PKT_ENCRYPTED && pkttype != PKT_PLAINTEXT | ||||
&& pkttype != PKT_COMPRESSED) | && pkttype != PKT_COMPRESSED) | ||||
{ | { | ||||
log_error ("%s: indeterminate length for invalid" | log_error ("%s: indeterminate length for invalid" | ||||
" packet type %d\n", iobuf_where (inp), pkttype); | " packet type %d\n", iobuf_where (inp), pkttype); | ||||
rc = gpg_error (GPG_ERR_INV_PACKET); | rc = gpg_error (GPG_ERR_INV_PACKET); | ||||
goto leave; | goto leave; | ||||
} | } | ||||
else if (ctx->sigs_only) | |||||
{ | |||||
log_error (_("indeterminate length packet of type %d in detached" | |||||
" signature\n"), pkttype); | |||||
rc = gpg_error (GPG_ERR_UNEXPECTED); | |||||
goto leave; | |||||
} | |||||
else if (onlykeypkts) | |||||
{ | |||||
log_error (_("indeterminate length packet of type %d in" | |||||
" keyring\n"), pkttype); | |||||
rc = gpg_error (GPG_ERR_UNEXPECTED); | |||||
goto leave; | |||||
} | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
for (; lenbytes; lenbytes--) | for (; lenbytes; lenbytes--) | ||||
{ | { | ||||
pktlen <<= 8; | pktlen <<= 8; | ||||
c = iobuf_get (inp); | c = iobuf_get (inp); | ||||
if (c == -1) | if (c == -1) | ||||
Show All 37 Lines | again: | ||||
} | } | ||||
rc = iobuf_write (out, hdr, hdrlen); | rc = iobuf_write (out, hdr, hdrlen); | ||||
if (!rc) | if (!rc) | ||||
rc = copy_packet (inp, out, pkttype, pktlen, partial); | rc = copy_packet (inp, out, pkttype, pktlen, partial); | ||||
goto leave; | goto leave; | ||||
} | } | ||||
if (with_uid && pkttype == PKT_USER_ID) | if (ctx->sigs_only) | ||||
switch (pkttype) | |||||
{ | |||||
case PKT_SIGNATURE: | |||||
case PKT_MARKER: | |||||
break; | |||||
default: | |||||
iobuf_skip_rest (inp, pktlen, partial); | |||||
*skip = 1; | |||||
rc = GPG_ERR_UNEXPECTED; | |||||
goto leave; | |||||
} | |||||
else if (with_uid && pkttype == PKT_USER_ID) | |||||
/* If ONLYKEYPKTS is set to 2, then we never skip user id packets, | /* If ONLYKEYPKTS is set to 2, then we never skip user id packets, | ||||
even if DO_SKIP is set. */ | even if DO_SKIP is set. */ | ||||
; | ; | ||||
else if (do_skip | else if (do_skip | ||||
/* type==0 is not allowed. This is an invalid packet. */ | /* type==0 is not allowed. This is an invalid packet. */ | ||||
|| !pkttype | || !pkttype | ||||
/* When ONLYKEYPKTS is set, we don't skip keys. */ | /* When ONLYKEYPKTS is set, we don't skip keys. */ | ||||
|| (onlykeypkts && pkttype != PKT_PUBLIC_SUBKEY | || (onlykeypkts && pkttype != PKT_PUBLIC_SUBKEY | ||||
▲ Show 20 Lines • Show All 2,925 Lines • Show Last 20 Lines |