aboutsummaryrefslogtreecommitdiffstats
path: root/g10/parse-packet.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2016-06-28g10: Fix --list-packets.NIIBE Yutaka1-1/+1
* g10/gpg.c (main): Call set_packet_list_mode after assignment of opt.list_packets. * g10/mainproc.c (do_proc_packets): Don't stop processing with --list-packets as the comment says. * g10/options.h (list_packets): Fix the comment. * g10/parse-packet.c: Fix the condition for opt.list_packets. -- (backport from 2.0 commit 4f336ed780cc2783395f3ff2b12b3ebb8e097f7b which is backport of master commit 52f65281f9743c42a48bf5a3354c9ab0ecdb681a) Debian-bug-id: 828109 Signed-off-by: NIIBE Yutaka <[email protected]>
2015-10-01gpg: Silence a compiler warning.Werner Koch1-4/+4
* g10/parse-packet.c (enum_sig_subpkt): Replace hack. -- GCC 5 failure reported by Kevin Locke <[email protected]> (backport from master commit 6a0c3fa19cfcdd590b96691e8a8ffb48fb5e0ec4)
2015-04-05gpg: Fix DoS while parsing mangled secret key packets.Werner Koch1-7/+43
* g10/parse-packet.c (parse_key): Check PKTLEN before calling mpi_read et al. -- Due to the missing length checks PKTLEN may turn negative. Because PKTLEN is an unsigned int the malloc in read_rest would try to malloc a too large number and terminate the process with "error reading rest of packet: Cannot allocate memory". Reported-by: Hanno Böck. Signed-off-by: Werner Koch <[email protected]> (backported from 2.0 commit 0aac920f23fd07e152fdb7385299c92bb9a4ade3)
2015-02-23Use inline functions to convert buffer data to scalars.Werner Koch1-20/+21
* include/host2net.h (buf16_to_ulong, buf16_to_uint): New. (buf16_to_ushort, buf16_to_u16): New. (buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New. -- This fixes sign extension on shift problems. Hanno Böck found a case with an invalid read due to this problem. To fix that almost all uses of "<< 24" and "<< 8" are changed by this patch to use an inline function from host2net.h. (back ported from commit 2183683bd633818dd031b090b5530951de76f392) Signed-off-by: Werner Koch <[email protected]> [dkg: rebased to STABLE-BRANCH-1-4] Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2015-02-23gpg: Fix a NULL-deref due to empty ring trust packets.Werner Koch1-3/+7
* g10/parse-packet.c (parse_trust): Always allocate a packet. -- Reported-by: Hanno Böck <[email protected]> Signed-off-by: Werner Koch <[email protected]> (back ported from commit 39978487863066e59bb657f5fe4e8baab510da7e) [dkg: rebased to STABLE-BRANCH-1-4] Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2015-02-23gpg: Limit the size of key packets to a sensible value.Werner Koch1-2/+28
* g10/parse-packet.c (MAX_KEY_PACKET_LENGTH): New. (MAX_UID_PACKET_LENGTH): New. (MAX_COMMENT_PACKET_LENGTH): New. (MAX_ATTR_PACKET_LENGTH): New. (parse_key): Limit the size of a key packet to 256k. (parse_user_id): Use macro for the packet size limit. (parse_attribute): Ditto. (parse_comment): Ditto. -- Without that it is possible to force gpg to allocate large amounts of memory by using a bad encoded MPI. This would be an too easy DoS. Another way to mitigate would be to change the MPI read function to allocate memory dynamically while reading the MPI. However, that complicates and possibly slows down the code. A too large key packet is in any case a sign for broken data and thus gpg should not use it. Reported-by: Hanno Böck GnuPG-bug-id: 1823 Signed-off-by: Werner Koch <[email protected]> (back ported from commit 382ba4b137b42d5f25a7e256bb7c053ee5ac7b64) [dkg: rebased to STABLE-BRANCH-1-4] Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2015-01-13gpg: Fix possible read of unallocated memoryWerner Koch1-4/+7
* g10/parse-packet.c (can_handle_critical): Check content length before calling can_handle_critical_notation. -- The problem was found by Jan Bee and gniibe proposed the used fix. Thanks. This bug can't be exploited: Only if the announced length of the notation is 21 or 32 a memcmp against fixed strings using that length would be done. The compared data is followed by the actual signature and thus it is highly likely that not even read of unallocated memory will happen. Nevertheless such a bug needs to be fixed. Signed-off-by: Werner Koch <[email protected]>
2014-11-24gpg: Fix use of uninit.value in listing sig subpkts.Werner Koch1-2/+7
* g10/parse-packet.c (dump_sig_subpkt): Print regex subpacket sanitized. -- We may not use "%s" to print an arbitrary buffer. At least "%.*s" should have been used. However, it is in general preferable to escape control characters while printf user data. Reported-by: Hanno Böck Signed-off-by: Werner Koch <[email protected]> (backported from commit 596ae9f5433ca3b0e01f7acbe06fd2e424c42ae8)
2014-11-24gpg: Fix off-by-one read in the attribute subpacket parser.Werner Koch1-0/+8
* g10/parse-packet.c (parse_attribute_subpkts): Check that the attribute packet is large enough for the subpacket type. -- Reported-by: Hanno Böck Signed-off-by: Werner Koch <[email protected]> (backported from commit 0988764397f99db4efef1eabcdb8072d6159af76)
2013-10-18Print the keyid for key packets with --list-packets.Werner Koch1-1/+11
* g10/parse-packet.c (parse_key): Add keyid printing. -- This is backport from GnuPG-2. Note that the --list-packets command is for debugging only and not part iof the stable API. Signed-off-by: Werner Koch <[email protected]>
2011-07-22Print the decoded iteration count witn --list-packets.Werner Koch1-13/+15
Fixes bug#1355.
2010-10-20Remove warnings on VMSWerner Koch1-1/+1
2010-06-18Backport bug fix. Fixes bug#1240.Werner Koch1-2/+10
2009-06-17Fix bug#1040.Werner Koch1-2/+2
2009-05-05Fix bug#931.Werner Koch1-20/+29
Silent a compiler warning.
2008-04-17Add Camellia-192.David Shaw1-3/+3
2008-03-17* parse-packet.c (parse_key): Parse a secret key encrypted withDavid Shaw1-1/+2
Camellia.
2007-10-27* parse-packet.c (parse_onepass_sig): Sigclass is hex, so include theDavid Shaw1-1/+1
0x.
2007-10-23Switched to GPLv3.Werner Koch1-4/+2
Updated gettext.
2007-04-04* parse-packet.c (parse_marker): New. Enforce that the markerDavid Shaw1-22/+58
contains 'P', 'G', 'P', and nothing but. (parse): Call it here. (skip_packet): No longer need to handle marker packets here.
2007-02-14* parse-packet.c (parse_signature): It's hex.David Shaw1-1/+1
* getkey.c (merge_selfsigs_subkey): Avoid listing the contents of a backsig when list mode is on. Noted by Timo Schulz.
2007-02-04Fix for Debian bug 402592Werner Koch1-3/+19
2007-01-15 * parse-packet.c (read_protected_v3_mpi): Make sure to stopWerner Koch1-1/+1
reading even for corrupted packets. * keygen.c (generate_user_id): Need to allocate one byte more. Reported by Felix von Leitner.
2006-10-13* parse-packet.c (parse_symkeyenc): Show the unpacked as well as theDavid Shaw1-1/+3
packed s2k iteration count. * main.h, options.h, gpg.c (encode_s2k_iterations, main), passphrase.c (hash_passphrase): Add --s2k-count option to specify the number of s2k hash iterations.
2006-07-26Fixed memory allocation bug and typos.Werner Koch1-3/+17
2006-06-09* parse-packet.c (parse_user_id): Cap the user ID size at 2048 bytes. David Shaw1-0/+14
This prevents a memory allocation attack with a very large user ID. A very large packet length could even cause the allocation (a u32) to wrap around to a small number. Noted by Evgeny Legerov on full-disclosure.
2006-05-23* parse-packet.c (dump_sig_subpkt, parse_signature), build-packet.cDavid Shaw1-7/+17
(build_sig_subpkt_from_sig), getkey.c (fixup_uidnode, merge_selfsigs_main, merge_selfsigs_subkey), keygen.c (keygen_add_key_expire): Fix meaning of key expiration and sig expiration subpackets - zero means "never expire" according to 2440, not "expire instantly".
2005-11-12* trustdb.h, trustdb.c (clean_key): New function to handle keyDavid Shaw1-24/+6
cleaning from one convenient place. * options.h, import.c (parse_import_options, clean_sigs_from_all_uids, import_one): Reduce clean options to two: clean and minimize. * parse-packet.c (setup_user_id): Remove. (parse_user_id, parse_attribute): Just use xmalloc_clear instead.
2005-09-02* parse-packet.c (enum_sig_subpkt, parse_signature,David Shaw1-12/+15
parse_attribute_subpkts): Make a number of warnings verbose items. These fire on many slightly mangled keys in the field, so the warning is becoming burdensome.
2005-07-28Implemented PKA trust modelWerner Koch1-0/+2
2005-07-27Converted all m_free to xfree etc.Werner Koch1-27/+27
2005-06-18(parse_signature): Use log_info for messagesWerner Koch1-2/+2
about missing timestamp or keyid. In case we don't use that key there won't be no further error and thus gpg does not need to return with an error.
2005-05-31Updated FSF street address and preparations for a release candidate.Werner Koch1-1/+2
2005-05-11* keygen.c (write_selfsigs): Rename from write_selfsig. Write the sameDavid Shaw1-7/+19
selfsig into both the pk and sk, so that someone importing their sk (which will get an autoconvert to the pk) won't end up with two selfsigs. (do_generate_keypair): Call it from here. * parse-packet.c (can_handle_critical_notation): New. Check for particular notation tags that we will accept when critical. Currently, that's only [email protected], since we know how to handle it (pass it through to a mail program). (can_handle_critical): Call it from here. (parse_one_sig_subpkt): Sanity check that notations are well-formed in that the internal lengths add up to the size of the subpacket.
2005-02-03Updated to match the switch to the NSIS installer.Werner Koch1-135/+159
2004-10-16* parse-packet.c (parse_one_sig_subpkt, enum_sig_subpkt): Don't BUG() onDavid Shaw1-10/+7
unknown subpackets. Rather, just return them silently.
2004-09-09* photoid.c: Include ttyio.h.Werner Koch1-26/+11
* parse-packet.c (skip_rest): Removed. Changed all callers to use the new iobuf_skip_reset. Orginal patch by Florian Weimer. * iobuf.c (iobuf_skip_rest): New. Orginal patch by Florian Weimer. Added new argument PARTIAL.
2004-07-15* g10.c (main): Alias --charset as --display-charset to help avoid theDavid Shaw1-2/+2
continuing confusion and make room for possible changes in devel. * parse-packet.c (parse_plaintext): Show the hex value for the literal packet mode since it may not be printable. * keygen.c (make_backsig): Make sure that the backsig was built successfully before we try and use it. * status.h, status.c (get_status_string), plaintext.c (handle_plaintext): New status tags PLAINTEXT and PLAINTEXT_LENGTH.
2004-04-23* keygen.c (make_backsig): If DO_BACKSIGS is not defined, do not createDavid Shaw1-3/+1
backsigs. * getkey.c (merge_selfsigs_subkey): Find 0x19 backsigs on subkey selfsigs and verify they are valid. If DO_BACKSIGS is not defined, fake this as always valid. * packet.h, parse-packet.c (parse_signature): Make parse_signature non-static so we can parse 0x19s in self-sigs. * main.h, sig-check.c (check_backsig): Check a 0x19 signature. (signature_check2): Give a backsig warning if there is no or a bad 0x19 with signatures from a subkey.
2004-04-22* parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt,David Shaw1-76/+88
can_handle_critical): Parse and display 0x19 signatures.
2004-03-03* build-packet.c (write_header2): Remove call to start old gpg partialDavid Shaw1-30/+22
length mode and change all callers. (do_plaintext): Turn off partial length encoding now that we're done writing the packet. (do_comment, do_user_id): Try for a headerlen of 2 since that's the smallest and most likely encoding for these packets. * parse-packet.c (parse): Remove call to start old gpg partial length mode.
2004-03-03* packet.h, free-packet.c (free_encrypted, free_plaintext), parse-packet.cDavid Shaw1-50/+54
(copy_packet, skip_packet, skip_rest, read_rest, parse_plaintext, parse_encrypted, parse_gpg_control): Use a flag to indicate partial or indeterminate encoding. This is the first step in some minor surgery to remove the old gpg partial length encoding.
2004-03-01* parse-packet.c (parse): Only data-type packets are allowed to useDavid Shaw1-28/+46
OpenPGP partial length encoding.
2004-02-15* build-packet.c (write_header2): If a suggested header length is providedDavid Shaw1-7/+7
along with a zero length, interpret this as an actual zero length packet and not as an indeterminate length packet. (do_comment, do_user_id): Use it here as these packets might be naturally zero length. * parse-packet.c (parse): Show packet type when failing due to an indeterminate length packet. * misc.c (parse_options): Only provide args for the true (i.e. not "no-xxx") form of options.
2003-10-01* g10.c (main): Add --no-groups to zero --group list.David Shaw1-5/+18
* encode.c (encode_simple): Allow for 32 bytes (256 bits) of symmetrically encrypted session key. Use --s2k-cipher-algo to choose cipher, rather than the default cipher. * parse-packet.c (parse_subkeyenc): Give a warning if an symmetrically encrypted session key is seen without salt. Show in --list-packets if a symetrically encrypted session key is present. * pubkey-enc.c (get_it): Always show cipher-not-in-prefs warning unless --quiet is set. Use text name of cipher in warning.
2003-09-30* keygen.c (do_add_key_flags, parse_parameter_usage): Add supportWerner Koch1-2/+22
the proposed AUTH key flag. * getkey.c (fixup_uidnode, merge_selfsigs_main) (merge_selfsigs_subkey, premerge_public_with_secret): Ditto. * keylist.c (print_capabilities): Ditto. * parse-packet.c (parse_key): Allow to parse the divert-to-card S2K mode. * build-packet.c (do_secret_key): Handle divert-to-card S2K * seckey-cert.c (is_secret_key_protected): Ditto. (check_secret_key): Ditto. * keygen.c (do_ask_passphrase): Renamed from ask_passphrase. * passphrase.c (ask_passphrase): New.
2003-08-26* mainproc.c (check_sig_and_print): Use two different preferred keyserverDavid Shaw1-0/+4
displays - one if the key is not present (to tell the user where to get the key), the other if it is present (to tell the user where the key can be refreshed). * packet.h, parse-packet.c (parse_signature): Set flag if a preferred keyserver is present. * keylist.c (list_keyblock_print): Show keyserver url in listings with list-option show-keyserver-url.
2003-08-13* packet.h, sig-check.c (signature_check2, do_check, do_check_messages):David Shaw1-8/+10
Provide a signing-key-is-revoked flag. Change all callers. * status.h, status.c (get_status_string): New REVKEYSIG status tag for a good signature from a revoked key. * mainproc.c (do_check_sig, check_sig_and_print): Use it here. * import.c (import_revoke_cert, merge_blocks, merge_sigs): Compare actual signatures on import rather than using keyid or class matching. This does not change actual behavior with a key, but does mean that all sigs are imported whether they will be used or not. * parse-packet.c (parse_signature): Don't give "signature packet without xxxx" warnings for experimental pk algorithms. An experimental algorithm may not have a notion of (for example) a keyid (i.e. PGP's x.509 stuff).
2003-07-10* parse-packet.c (parse_signature): No need to reserve 8 bytes for theDavid Shaw1-5/+2
unhashed signature cache any longer. * misc.c (pct_expando): Add two new expandos - signer's fingerprint (%g), and signer's primary fingerprint (%p). * Makefile.am: Include W32LIBS where appropriate. * g10.c (main): Add --rfc2440 alias for --openpgp since in a few months, they won't be the same thing. * keyserver.c (parse_keyserver_uri): Accept "http" as an alias for "hkp", since it is occasionally written that way. (keyserver_spawn): Use ascii_isspace to avoid locale issues. * keygen.c (ask_user_id): Make --allow-freeform-uid apply to the email field as well as the name field, and allow mixing fields when it is set. * options.skel: Use subkeys.pgp.net as the default keyserver. * trustdb.c (validate_one_keyblock): Certifications on revoked or expired uids do not count in the web of trust. * signal.c (init_one_signal, pause_on_sigusr, do_block): Only use sigprocmask() if we have sigset_t, and only use sigaction() if we have struct sigaction. This is for Forte c89 on Solaris which seems to define only the function call half of the two pairs by default. (pause_on_sigusr): Typo. (do_block): If we can't use sigprocmask() and sigset_t, try to get the number of signals from NSIG as well as MAXSIG, and if we can't, fail with an explanation. * signal.c, tdbio.c: Comment out the transaction code. It was not used in this version, and was causing some build problems on quasi-posix platforms (Solaris and Forte c89). * keylist.c (list_keyblock_colon): Don't include validity values when listing secret keys since they can be incorrect and/or misleading. This is a temporary kludge, and will be handled properly in 1.9/2.0. * mainproc.c (check_sig_and_print): Only show the "key available from" preferred keyserver line if the key is not currently present. * keyedit.c (sign_uids): Do not sign expired uids without --expert (same behavior as revoked uids). Do not allow signing a user ID without a self-signature. --expert overrides. Add additional prompt to the signature level question. (menu_expire): When changing expiration dates, don't replace selfsigs on revoked uids since this would effectively unrevoke them. There is also no point in replacing expired selfsigs. This is bug #181 * g10.c (add_notation_data): Make sure that only ascii is passed to iscntrl. Noted by Christian Biere. * getkey.c (classify_user_id2): Replaced isspace by spacep * keygen.c (ask_user_id): Ditto. (get_parameter_algo): Ditto. * keyedit.c (keyedit_menu): Ditto. * tdbdump.c (import_ownertrust): Ditto. s/isxdigit/hexdigitp/. * revoke.c (ask_revocation_reason): * keyserver.c (keyserver_spawn): Dito.
2003-06-10* parse-packet.c (parse): Disallow old style partial length forWerner Koch1-2/+22
all key material packets to avoid possible corruption of keyrings.