diff options
author | Werner Koch <[email protected]> | 1999-08-31 15:30:12 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1999-08-31 15:30:12 +0000 |
commit | 88a916cdd40e43312ffcde6bb1c157fe1c122f74 (patch) | |
tree | d5298986a0bad2aff797fd981f99fb3cb6f99ba9 | |
parent | See ChangeLog: Mon Aug 30 20:38:33 CEST 1999 Werner Koch (diff) | |
download | gnupg-88a916cdd40e43312ffcde6bb1c157fe1c122f74.tar.gz gnupg-88a916cdd40e43312ffcde6bb1c157fe1c122f74.zip |
See ChangeLog: Tue Aug 31 17:20:44 CEST 1999 Werner Koch
-rw-r--r-- | BUGS | 4 | ||||
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | NEWS | 11 | ||||
-rw-r--r-- | README | 10 | ||||
-rw-r--r-- | THOUGHTS | 2 | ||||
-rw-r--r-- | TODO | 17 | ||||
-rw-r--r-- | checks/ChangeLog | 5 | ||||
-rwxr-xr-x | checks/defs.inc | 1 | ||||
-rw-r--r-- | configure.in | 34 | ||||
-rw-r--r-- | doc/DETAILS | 14 | ||||
-rw-r--r-- | doc/FAQ | 2 | ||||
-rw-r--r-- | doc/HACKING | 6 | ||||
-rw-r--r-- | doc/OpenPGP | 2 | ||||
-rw-r--r-- | doc/gpg.sgml | 17 | ||||
-rw-r--r-- | g10/ChangeLog | 12 | ||||
-rw-r--r-- | g10/helptext.c | 6 | ||||
-rw-r--r-- | g10/keyedit.c | 20 | ||||
-rw-r--r-- | g10/keylist.c | 16 | ||||
-rw-r--r-- | g10/mainproc.c | 27 | ||||
-rw-r--r-- | g10/packet.h | 3 | ||||
-rw-r--r-- | g10/plaintext.c | 47 | ||||
-rw-r--r-- | include/ttyio.h | 1 | ||||
-rw-r--r-- | include/util.h | 3 | ||||
-rw-r--r-- | util/ChangeLog | 11 | ||||
-rw-r--r-- | util/miscutil.c | 25 | ||||
-rw-r--r-- | util/strgutil.c | 204 | ||||
-rw-r--r-- | util/ttyio.c | 23 |
27 files changed, 367 insertions, 162 deletions
@@ -30,8 +30,8 @@ and after about half a day in the rsync snapshots. [is this bug still alive? - can someone please check it] [ **] #6 1999-02-22 <[email protected]> 0.9.3 - Buserror on IRIX 6.4: Crash while doing a keygen. I think while creating - the prime. Other buserrors are reported when doing a "gpg README" + Bus error on IRIX 6.4: Crash while doing a keygen. I think while creating + the prime. Other bus errors are reported when doing a "gpg README" on sparc-solaris2.6. --> Solaris fixed. --> IRIX bug still there but someone should test this again! @@ -1,3 +1,9 @@ +Tue Aug 31 17:20:44 CEST 1999 Werner Koch <[email protected]> + + + * configure.in: Minor changes to the OS/2 and Mingw32 system labels. + Add a printable name for Hurd. + Mon Aug 30 20:38:33 CEST 1999 Werner Koch <[email protected]> @@ -1,3 +1,12 @@ +Noteworthy changes in version 0.9.xx +------------------------------------ + + * UTF-8 strings are now correctly printed (if --charset is set correctly). + Output of --with-colons is remains C-style escaped UTF8. + + * Workaround for a problem with PGP 5 detached signature in textmode. + + Noteworthy changes in version 0.9.10 ------------------------------------ @@ -58,7 +67,7 @@ Noteworthy changes in version 0.9.7 ----------------------------------- * Add some work arounds for a bugs in pgp 2 which led to bad signatures - when used with canoncial texts in some cases. + when used with canonical texts in some cases. * Enhanced some status outputs. @@ -29,7 +29,7 @@ implementation of ElGamal signatures is *not* insecure). Symmetric algorithms are: 3DES, Blowfish, CAST5 and Twofish (GnuPG does not yet create Twofish encrypted messages because there no agreement - in the OpenPG WG on how to use it together with a MDC algorithm) + in the OpenPGP WG on how to use it together with a MDC algorithm) Digest algorithms available are MD5, RIPEMD160, SHA1, and TIGER/192. @@ -116,7 +116,7 @@ "pub 768R/0C9857A5 1995-09-30 Werner Koch <[email protected]>" - The finperprint of this key is published in printed form in the + The fingerprint of this key is published in printed form in the "Global Trust Register for 1998", ISBN 0-9532397-0-5. @@ -130,7 +130,7 @@ fd9351b26b3189c1d577f0970f9dcadc gnupg-x.y.z.tar.gz Now check that this checksum is _exactly_ the same as the one - published via the anouncement list and probably via Usenet. + published via the announcement list and probably via Usenet. @@ -414,7 +414,7 @@ "+Heinrich Heine duesseldorf" - All words must match excatly (not case sensitive) and appear in + All words must match exactly (not case sensitive) and appear in any order in the user ID. Words are any sequences of letters, digits, the underscore and characters with bit 7 set. @@ -438,7 +438,7 @@ If you use the option "--batch", GnuPG runs in non-interactive mode and never prompts for input data. This does not even allow entering the passphrase. Until we have a better solution (something like ssh-agent), - you can use the option "--passphrase-fd n", which works like PGPs + you can use the option "--passphrase-fd n", which works like PGP's PGPPASSFD. Batch mode also causes GnuPG to terminate as soon as a BAD signature is @@ -23,7 +23,7 @@ conditional. more secure than swapping out to the swap disk? I don't believe so because if an attacker has access to the physical box (and he needs this to look at the swap area) he can also - leave a trojan horse which is far more easier than to analyze + leave a Trojan horse which is far more easier than to analyze memory dumps. Question: Is it possible that a Unix pages an old (left over by some other process) swap page in for another process - this should be considered a serious design @@ -1,13 +1,4 @@ - * use-emmbeded-filename ist nicht dokumentiert. - - * --disable-asm should still assemble _udiv_qrnnd when needed - - * Skip RO keyrings when importing a key. - - * help the translaters to catch changes made to helptext.c - and tell that, that they have to translate those strings. - Scheduled for 1.1 ----------------- * With option -i prompt before adding a key to the keyring and show some @@ -22,10 +13,14 @@ Scheduled for 1.1 * print a warning when a revoked/expired _secret_ key is used. + * --disable-asm should still assemble _udiv_qrnnd when needed + + * Skip RO keyrings when importing a key. + Nice to have ------------ - * Offcial test vectors for 3DES-EDE3 + * Official test vectors for 3DES-EDE3 * use DEL and ^H for erasing the previous character (util/ttyio.c). or better readline. * Print a warning if the directory mode is wrong. @@ -48,7 +43,7 @@ Nice to have verification status of the message to the output (i.e. write something to the --output file and not only to stderr. * configure option where to find zlib - * Check the beginning of file to detect already compresssed files (gzip, + * Check the beginning of file to detect already compressed files (gzip, bzip2, xdelta and some picture formats) * Display more validity information about the user IDs at certain places. We need a more general function to extract such kind of info from the diff --git a/checks/ChangeLog b/checks/ChangeLog index d5520589e..8e043bf71 100644 --- a/checks/ChangeLog +++ b/checks/ChangeLog @@ -1,3 +1,8 @@ +Tue Aug 31 17:20:44 CEST 1999 Werner Koch <[email protected]> + + + * defs.inc: set LC_ALL empty + Wed Aug 4 10:34:18 CEST 1999 Werner Koch <[email protected]> diff --git a/checks/defs.inc b/checks/defs.inc index 058a23370..d5fdc8af7 100755 --- a/checks/defs.inc +++ b/checks/defs.inc @@ -28,6 +28,7 @@ exp_files="" # The testscripts expect the original language LANG= LANGUAGE= +LC_ALL= #-------------------------------- #------ utility functions ------- diff --git a/configure.in b/configure.in index eee8c76d6..e72e7be4d 100644 --- a/configure.in +++ b/configure.in @@ -179,12 +179,12 @@ fi try_gettext=yes try_gdbm=yes case "${target}" in - i386--mingw32) + *-*-mingw32) # special stuff for Windoze NT cross_compiling=yes - CC="i386--mingw32-gcc" - CPP="i386--mingw32-gcc -E" - RANLIB="i386--mingw32-ranlib" + CC="${target}-gcc" + CPP="${target}-gcc -E" + RANLIB="${target}-ranlib" ac_cv_have_dev_random=no AC_DEFINE(USE_ONLY_8DOT3) AC_DEFINE(HAVE_DRIVE_LETTERS) @@ -192,7 +192,7 @@ case "${target}" in try_gettext="no" try_gdbm="no" ;; - i386-emx-os2 | i[3456]86-pc-os2*emx ) + i?86-emx-os2 | i?86-*-os2*emx ) # OS/2 with the EMX environment ac_cv_have_dev_random=no AC_DEFINE(HAVE_DRIVE_LETTERS) @@ -201,7 +201,7 @@ case "${target}" in try_gdbm="no" ;; - i*86-*-msdosdjgpp*) + i?86-*-msdosdjgpp*) # DOS with the DJGPP environment ac_cv_have_dev_random=no AC_DEFINE(HAVE_DRIVE_LETTERS) @@ -238,18 +238,22 @@ fi case "${target}" in - i386--mingw32) + *-*-mingw32) PRINTABLE_OS_NAME="MingW32" ;; - i386-emx-os2 | i[3456]86-pc-os2*emx ) + i?86-emx-os2 | i?86-*-os2*emx ) PRINTABLE_OS_NAME="OS/2" ;; + i?86-*-msdosdjgpp*) + PRINTABLE_OS_NAME="MSDOS/DJGPP" + try_dynload=no + ;; *-linux*) PRINTABLE_OS_NAME="GNU/Linux" ;; - i*86-*-msdosdjgpp*) - PRINTABLE_OS_NAME="MSDOS/DJGPP" - try_dynload=no +dnl let that after linux to avoid gnu-linux problems + *-gnu*) + PRINTABLE_OS_NAME="GNU/Hurd" ;; *) PRINTABLE_OS_NAME=`uname -s || echo "Unknown"` @@ -482,16 +486,16 @@ if test "$use_static_rnd" = default; then static_modules="$static_modules rndlinux" else case "${target}" in - i386--mingw32) + *-*-mingw32) static_modules="$static_modules rndw32" ;; - i386-emx-os2|i[3456]86-pc-os2*emx) + i?86-emx-os2|i?86-*-os2*emx) static_modules="$static_modules rndos2" ;; m68k-atari-mint) static_modules="$static_modules rndatari" ;; - i*86-*-msdosdjgpp*) + i?86-*-msdosdjgpp*) static_modules="$static_modules" ;; *) @@ -525,7 +529,7 @@ if test "$print_egd_notice" = "yes"; then *** in Perl and available at the GnuPG FTP servers. For more information *** consult the GnuPG webpages: *** -*** http://www.gnupg.org/donwload.html#egd +*** http://www.gnupg.org/download.html#egd *** *** You may want to run ./configure with --enable-static-rnd=none to be *** able to load the EGD client code dynamically; this way you can choose diff --git a/doc/DETAILS b/doc/DETAILS index 67ca23c16..7c1e11edf 100644 --- a/doc/DETAILS +++ b/doc/DETAILS @@ -52,7 +52,7 @@ More fields may be added later. If field 1 has the tag "pkd", a listing looks like this: pkd:0:1024:B665B1435F4C2 .... FF26ABB: ! ! !-- the value - ! !------ for infomation number of bits in the value + ! !------ for information number of bits in the value !--------- index (eg. DSA goes from 0 to 3: p,q,g,y) @@ -97,7 +97,7 @@ more arguments in future versions. ENC_TO <long keyid> <keytype> <keylength> The message is encrypted to this keyid. keytype is the numerical value of the public key algorithm, - kenlength is the length of the key or 0 if it is not known + keylength is the length of the key or 0 if it is not known (which is currently always the case). NODATA <what> @@ -147,7 +147,7 @@ more arguments in future versions. No passphrase was supplied. An application which encounters this message may want to stop parsing immediately because the next message will probably be a BAD_PASSPHRASE. However, if the application - is a wrapper around the key edit menu functionalty it might not + is a wrapper around the key edit menu functionality it might not make sense to stop parsing but simply ignoring the following PAD_PASSPHRASE. @@ -167,7 +167,7 @@ more arguments in future versions. The decryption process succeeded. This means, that either the correct secret key has been used or the correct passphrase for a conventional encrypted message was given. The program - itself may return an errorcode becuase it may not be possible to + itself may return an errorcode because it may not be possible to verify a signature for some reasons. NO_PUBKEY <long keyid> @@ -578,7 +578,7 @@ The standard http URL encoded query parameters are this (always key=value): are not searched for and the order of the words doesn't matter (but see next option). -- exact=on. This switch tells the hkp server to only report exact mathing +- exact=on. This switch tells the hkp server to only report exact matching keys back. In this case the order and the "delimiters" are important. - fingerprint=on. Also reports the fingerprints when used with 'index' or @@ -592,7 +592,7 @@ A better way to to this would be a request like: /pks/lookup/<gnupg_formatierte_user_id>?op=<operation> -this can be implemented using Hurd's translater mechanism. -However, I think the whole key server stuff has to be re-thougth; +this can be implemented using Hurd's translator mechanism. +However, I think the whole key server stuff has to be re-thought; I have some ideas and probably create a white paper. @@ -333,7 +333,7 @@ the displayed charset is the one you have activated on your system "iso-8859-1" is the most used one, so this is the default. You can change the charset with the option "--charset". It is important that - you active characterset matches the one displayed - if not, restrict + you active character set matches the one displayed - if not, restrict yourself to plain 7 bit ASCII and no mapping has to be done. Q: How do I transfer owner trust values from PGP to GnuPG? diff --git a/doc/HACKING b/doc/HACKING index bc06a7064..6f4c9ffd8 100644 --- a/doc/HACKING +++ b/doc/HACKING @@ -46,7 +46,7 @@ of the CVS head revision is also available. See rsync(1) and try Special Tools ============= -Documention is based on the docbook DTD. Actually we have only the +Documentation is based on the docbook DTD. Actually we have only the man page for now. To build a man page you need the docbook-to-man tool and all the other thinks needed for SGML processing. Debian comes with the docbook tools and you only need this docbook-to-man @@ -203,7 +203,7 @@ How to use the cipher functions cipher/cipher.c implements the interface to symmetric encryption functions. As usual you have a function to open a cipher (which returns a handle to be used with all other functions), some functions to set the key and other stuff and -a encrypt and decrypt function which does the real work. YOu probably know +a encrypt and decrypt function which does the real work. You probably know how to work with files - so it should really be easy to work with these functions. Here is an example: @@ -211,7 +211,7 @@ functions. Here is an example: hd = cipher_open( CIPHER_ALGO_TWOFISH, CIPHER_MODE_CFB, 0 ); if( !hd ) - oops( use other funtion to check for the real error ); + oops( use other function to check for the real error ); rc = cipher_setkey( hd, key256bit, 32 ) ) if( rc ) oops( weak key or something like this ); diff --git a/doc/OpenPGP b/doc/OpenPGP index a32da4723..148032ad9 100644 --- a/doc/OpenPGP +++ b/doc/OpenPGP @@ -39,7 +39,7 @@ * PGP 5.x does not accept V4 signatures for anything other than key material. The GnuPG option --force-v3-sigs mimics this - behaviour. + behavior. * PGP 5.x does not recognize the "five-octet" lengths in new-format headers or in signature subpacket lengths. diff --git a/doc/gpg.sgml b/doc/gpg.sgml index b4f0873cb..a5595400f 100644 --- a/doc/gpg.sgml +++ b/doc/gpg.sgml @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA --> <!-- This file should be processed by docbook-to-man to - create a manual page. This program has currenlty the bug + create a manual page. This program has currently the bug not to remove leading white space. So this source file does not look very pretty @@ -469,7 +469,7 @@ values will be overwritten. <varlistentry> <term>--print-md <parameter>algo</parameter> &OptParmFiles;</term> <listitem><para> -Print message digest og algorithm ALGO for all given files of stdin. +Print message digest of algorithm ALGO for all given files of stdin. If "*" is used for the algorithm, digests for all available algorithms are printed. </para></listitem></varlistentry> @@ -480,8 +480,8 @@ are printed. <optional><parameter>count</parameter></optional></term> <listitem><para> Emit COUNT random bytes of the given quality level. If count is not given -or zero, an endless sequenece of random bytes will be emitted. -PLEASE, don't use this command unless you know waht you are doing, it may +or zero, an endless sequence of random bytes will be emitted. +PLEASE, don't use this command unless you know what you are doing, it may remove precious entropy from the system! </para></listitem></varlistentry> @@ -915,6 +915,13 @@ Use &ParmString; as the name of file which is stored in messages. </para></listitem></varlistentry> +<varlistentry> +<term>--use-embedded-filename</term> +<listitem><para> +Try to create a file with a name as embedded in the data. +This can be a dangerous option as it allows to overwrite files. +</para></listitem></varlistentry> + <varlistentry> <term>--completes-needed &ParmN;</term> @@ -1109,7 +1116,7 @@ This option might not be implemented yet. <term>--allow-non-selfsigned-uid</term> <listitem><para> Allow the import of keys with user IDs which are not self-signed. -This is only allows the import - key validation will fail und you +This is only allows the import - key validation will fail and you have to check the validity of the key my other means. This hack is needed for some German keys generated with pgp 2.6.3in. You should really avoid using it, because OpenPGP has better mechanics to do separate signing diff --git a/g10/ChangeLog b/g10/ChangeLog index 329b3a7b1..dec722de9 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,15 @@ +Tue Aug 31 17:20:44 CEST 1999 Werner Koch <[email protected]> + + + * plaintext.c (do_hash): Hash CR,LF for a single CR. + (ask_for_detached_datafile): Changed arguments to be closer to + those of hash_datafiles and cleanup the code a bit. + * mainproc.c (proc_tree): Workaround for pgp5 textmode detached + signatures. Changed behavior of asking for data file to be the same + as with provided data files. + + * keylist.c (list_keyblock): Use UTF8 print functions. + Mon Aug 30 20:38:33 CEST 1999 Werner Koch <[email protected]> diff --git a/g10/helptext.c b/g10/helptext.c index d34a3a9ac..e6957da3b 100644 --- a/g10/helptext.c +++ b/g10/helptext.c @@ -103,7 +103,7 @@ static struct helptexts { const char *key; const char *help; } helptexts[] = { { "keygen.valid", N_( - "Enter the required value as shown in the pronpt.\n" + "Enter the required value as shown in the prompt.\n" "It is possible to enter a ISO date (YYYY-MM-DD) but you won't\n" "get a good error response - instead the system tries to interpret\n" "the given value as an interval." @@ -176,8 +176,8 @@ static struct helptexts { const char *key; const char *help; } helptexts[] = { { "keyedit.delsig.valid", N_( "This is a valid signature on the key; you normally don't want\n" - "to delete this signature may be important to establish a trust\n" - "connection to the key or another key certified by this key." + "to delete this signature because it may be important to establish a\n" + "trust connection to the key or another key certified by this key." )}, { "keyedit.delsig.unknown", N_( "This signature can't be checked because you don't have the\n" diff --git a/g10/keyedit.c b/g10/keyedit.c index db5c0050f..d54e90d6c 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -157,7 +157,7 @@ print_and_check_one_sig( KBNODE keyblock, KBNODE node, else { size_t n; char *p = get_user_id( sig->keyid, &n ); - tty_print_string( p, n > 40? 40 : n ); + tty_print_utf8_string( p, n > 40? 40 : n ); m_free(p); } tty_printf("\n"); @@ -192,7 +192,7 @@ check_all_keysigs( KBNODE keyblock, int only_selected ) selected = (node->flag & NODFLG_SELUID); if( selected ) { tty_printf("uid "); - tty_print_string( uid->name, uid->len ); + tty_print_utf8_string( uid->name, uid->len ); tty_printf("\n"); if( anyuid && !has_selfsig ) mis_selfsig++; @@ -330,7 +330,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified, int local ) "Are you really sure that you want to sign this key\n" "with your key: \"")); p = get_user_id( sk_keyid, &n ); - tty_print_string( p, n ); + tty_print_utf8_string( p, n ); m_free(p); p = NULL; tty_printf("\"\n\n"); @@ -1112,7 +1112,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, tty_printf("(%d)* ", i); else tty_printf("(%d) ", i); - tty_print_string( uid->name, uid->len ); + tty_print_utf8_string( uid->name, uid->len ); tty_printf("\n"); if( with_prefs ) show_prefs( keyblock, uid ); @@ -1138,7 +1138,7 @@ show_key_and_fingerprint( KBNODE keyblock ) } else if( node->pkt->pkttype == PKT_USER_ID ) { PKT_user_id *uid = node->pkt->pkt.user_id; - tty_print_string( uid->name, uid->len ); + tty_print_utf8_string( uid->name, uid->len ); break; } } @@ -1322,7 +1322,7 @@ menu_delsig( KBNODE pub_keyblock ) int okay, valid, selfsig, inv_sig, no_key, other_err; tty_printf("uid "); - tty_print_string( uid->name, uid->len ); + tty_print_utf8_string( uid->name, uid->len ); tty_printf("\n"); okay = inv_sig = no_key = other_err = 0; @@ -1708,8 +1708,8 @@ ask_revoke_sig( KBNODE keyblock, KBNODE node ) } tty_printf(_("user ID: \"")); - tty_print_string( unode->pkt->pkt.user_id->name, - unode->pkt->pkt.user_id->len ); + tty_print_utf8_string( unode->pkt->pkt.user_id->name, + unode->pkt->pkt.user_id->len ); tty_printf(_("\"\nsigned with your key %08lX at %s\n"), sig->keyid[1], datestr_from_sig(sig) ); @@ -1744,7 +1744,7 @@ menu_revsig( KBNODE keyblock ) PKT_user_id *uid = node->pkt->pkt.user_id; /* Hmmm: Should we show only UIDs with a signature? */ tty_printf(" "); - tty_print_string( uid->name, uid->len ); + tty_print_utf8_string( uid->name, uid->len ); tty_printf("\n"); } else if( node->pkt->pkttype == PKT_SIGNATURE @@ -1781,7 +1781,7 @@ menu_revsig( KBNODE keyblock ) if( node->pkt->pkttype == PKT_USER_ID ) { PKT_user_id *uid = node->pkt->pkt.user_id; tty_printf(" "); - tty_print_string( uid->name, uid->len ); + tty_print_utf8_string( uid->name, uid->len ); tty_printf("\n"); } else if( node->pkt->pkttype == PKT_SIGNATURE ) { diff --git a/g10/keylist.c b/g10/keylist.c index 02a265394..91a13afaf 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -255,10 +255,15 @@ list_keyblock( KBNODE keyblock, int secret ) else printf("uid%*s", 28, ""); } - print_string( stdout, node->pkt->pkt.user_id->name, - node->pkt->pkt.user_id->len, opt.with_colons ); - if( opt.with_colons ) + if( opt.with_colons ) { + print_string( stdout, node->pkt->pkt.user_id->name, + node->pkt->pkt.user_id->len, ':' ); putchar(':'); + } + else + print_utf8_string( stdout, node->pkt->pkt.user_id->name, + node->pkt->pkt.user_id->len ); + putchar('\n'); if( !any ) { if( opt.fingerprint ) @@ -402,7 +407,10 @@ list_keyblock( KBNODE keyblock, int secret ) else { size_t n; char *p = get_user_id( sig->keyid, &n ); - print_string( stdout, p, n, opt.with_colons ); + if( opt.with_colons ) + print_string( stdout, p, n, ':' ); + else + print_utf8_string( stdout, p, n ); m_free(p); } if( opt.with_colons ) diff --git a/g10/mainproc.c b/g10/mainproc.c index 99713f9a4..033157269 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -1158,8 +1158,8 @@ proc_tree( CTX c, KBNODE node ) c->signed_data, c->sigfilename, n1? (n1->pkt->pkt.onepass_sig->sig_class == 0x01):0 ); else - rc = ask_for_detached_datafile( &c->mfx, - iobuf_get_fname(c->iobuf)); + rc = ask_for_detached_datafile( c->mfx.md, c->mfx.md2, + iobuf_get_fname(c->iobuf), 0 ); if( rc ) { log_error("can't hash datafile: %s\n", g10_errstr(rc)); return; @@ -1173,6 +1173,7 @@ proc_tree( CTX c, KBNODE node ) PKT_signature *sig = node->pkt->pkt.signature; if( !c->have_data ) { + /* detached signature */ free_md_filter_context( &c->mfx ); c->mfx.md = md_open(sig->digest_algo, 0); if( sig->digest_algo == DIGEST_ALGO_MD5 @@ -1180,15 +1181,16 @@ proc_tree( CTX c, KBNODE node ) /* enable a workaround for a pgp2 bug */ c->mfx.md2 = md_open( DIGEST_ALGO_MD5, 0 ); } - #if 0 - #warning md_start_debug enabled - md_start_debug( c->mfx.md, "det1" ); - if( c->mfx.md2 ) - md_start_debug( c->mfx.md2, "det2" ); - #endif + else if( sig->digest_algo == DIGEST_ALGO_SHA1 + && sig->pubkey_algo == PUBKEY_ALGO_DSA + && sig->sig_class == 0x01 ) { + /* enable the workaround also for pgp5 when the detached + * signature has been created in textmode */ + c->mfx.md2 = md_open( sig->digest_algo, 0 ); + } /* Here we have another hack to work around a pgp 2 bug * It works by not using the textmode for detached signatures; - * this will let the first signazure check (on md) fail + * this will let the first signature check (on md) fail * but the second one (on md2) which adds an extra CR should * then produce the "correct" hash. This is very, very ugly * hack but it may help in some cases (and break others) @@ -1196,10 +1198,11 @@ proc_tree( CTX c, KBNODE node ) if( c->sigs_only ) rc = hash_datafiles( c->mfx.md, c->mfx.md2, c->signed_data, c->sigfilename, - c->mfx.md2? 0 :(sig->sig_class == 0x01) ); + c->mfx.md2? 0 :(sig->sig_class == 0x01) ); else - rc = ask_for_detached_datafile( &c->mfx, - iobuf_get_fname(c->iobuf)); + rc = ask_for_detached_datafile( c->mfx.md, c->mfx.md2, + iobuf_get_fname(c->iobuf), + c->mfx.md2? 0 :(sig->sig_class == 0x01) ); if( rc ) { log_error("can't hash datafile: %s\n", g10_errstr(rc)); return; diff --git a/g10/packet.h b/g10/packet.h index 91253ebe2..50ea65b3f 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -334,7 +334,8 @@ int encrypt_data( PKT_encrypted *ed, DEK *dek ); /*-- plaintext.c --*/ int handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, int nooutput, int clearsig ); -int ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname ); +int ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2, + const char *inname, int textmode ); /*-- comment.c --*/ int write_comment( IOBUF out, const char *s ); diff --git a/g10/plaintext.c b/g10/plaintext.c index 878bdc46b..7411a4b16 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -249,7 +249,8 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, * INFILE is the name of the input file. */ int -ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname ) +ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2, + const char *inname, int textmode ) { char *answer = NULL; IOBUF fp; @@ -285,18 +286,12 @@ ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname ) if( !fp ) { if( opt.verbose ) log_info(_("reading stdin ...\n")); - while( (c = getchar()) != EOF ) { - if( mfx->md ) - md_putc(mfx->md, c ); - } - } - else { - while( (c = iobuf_get(fp)) != -1 ) { - if( mfx->md ) - md_putc(mfx->md, c ); - } - iobuf_close(fp); + fp = iobuf_open( NULL ); + assert(fp); } + do_hash( md, md2, fp, textmode ); + iobuf_close(fp); + leave: m_free(answer); @@ -315,16 +310,32 @@ do_hash( MD_HANDLE md, MD_HANDLE md2, IOBUF fp, int textmode ) iobuf_push_filter( fp, text_filter, &tfx ); } if( md2 ) { /* work around a strange behaviour in pgp2 */ + /* It seems that at least PGP5 converts a single CR to a CR,LF too */ + int lc = -1; while( (c = iobuf_get(fp)) != -1 ) { - if( c == '\n' ) - md_putc(md2, '\r' ); - md_putc(md, c ); - md_putc(md2, c ); + if( c == '\n' && lc == '\r' ) + md_putc(md2, c); + else if( c == '\n' ) { + md_putc(md2, '\r'); + md_putc(md2, c); + } + else if( c != '\n' && lc == '\r' ) { + md_putc(md2, '\n'); + md_putc(md2, c); + } + else + md_putc(md2, c); + + if( md ) + md_putc(md, c ); + lc = c; } } else { - while( (c = iobuf_get(fp)) != -1 ) - md_putc(md, c ); + while( (c = iobuf_get(fp)) != -1 ) { + if( md ) + md_putc(md, c ); + } } } diff --git a/include/ttyio.h b/include/ttyio.h index 24eedebaa..7992d85e8 100644 --- a/include/ttyio.h +++ b/include/ttyio.h @@ -23,6 +23,7 @@ int tty_batchmode( int onoff ); void tty_printf( const char *fmt, ... ); void tty_print_string( byte *p, size_t n ); +void tty_print_utf8_string( byte *p, size_t n ); char *tty_get( const char *prompt ); char *tty_get_hidden( const char *prompt ); void tty_kill_prompt(void); diff --git a/include/util.h b/include/util.h index 6feab3211..8eec982cc 100644 --- a/include/util.h +++ b/include/util.h @@ -153,6 +153,7 @@ const char *strtimevalue( u32 stamp ); const char *strtimestamp( u32 stamp ); /* GMT */ const char *asctimestamp( u32 stamp ); /* localized */ void print_string( FILE *fp, const byte *p, size_t n, int delim ); +void print_utf8_string( FILE *fp, const byte *p, size_t n ); char *make_printable_string( const byte *p, size_t n, int delim ); int answer_is_yes( const char *s ); int answer_is_yes_no_quit( const char *s ); @@ -175,7 +176,7 @@ int string_count_chr( const char *string, int c ); int set_native_charset( const char *newset ); const char* get_native_charset(void); char *native_to_utf8( const char *string ); -char *utf8_to_native( const char *string ); +char *utf8_to_native( const char *string, size_t length ); int check_utf8_string( const char *string ); #ifndef HAVE_MEMICMP diff --git a/util/ChangeLog b/util/ChangeLog index 95b06019a..a451e4a9a 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,14 @@ +Tue Aug 31 17:20:44 CEST 1999 Werner Koch <[email protected]> + + + * strgutil (utf8_to_native): Implemented. + (check_utf8_string): Removed. + + * miscutil.c (make_printable_string): Fixed possible buffer overflow. + (print_utf8_string): New. + + * ttyio.c (tty_print_utf8_string): New. + Mon Aug 30 20:38:33 CEST 1999 Werner Koch <[email protected]> diff --git a/util/miscutil.c b/util/miscutil.c index 2b95d97d6..eb72415bb 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -194,6 +194,29 @@ print_string( FILE *fp, const byte *p, size_t n, int delim ) } /**************** + * Print an UTF8 string to FP and filter all control characters out. + */ +void +print_utf8_string( FILE *fp, const byte *p, size_t n ) +{ + size_t i; + char *buf; + + /* we can handle plain ascii simpler, so check for it first */ + for(i=0; i < n; i++ ) { + if( p[i] & 0x80 ) + break; + } + if( i < n ) { + buf = utf8_to_native( p, n ); + fputs( buf, fp ); + m_free( buf ); + } + else + print_string( fp, p, n, 0 ); +} + +/**************** * This function returns a string which is suitable for printing * Caller must release it with m_free() */ @@ -211,7 +234,7 @@ make_printable_string( const byte *p, size_t n, int delim ) || *p=='\v' || *p=='\b' || !*p ) buflen += 2; else - buflen += 3; + buflen += 4; } else buflen++; diff --git a/util/strgutil.c b/util/strgutil.c index 87eaad423..9ab63a047 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -376,77 +376,161 @@ native_to_utf8( const char *string ) /**************** - * Convert string, which is in UTF8 to native encoding. Replace - * illegal encodings by some "\xnn". + * Convert string, which is in UTF8 to native encoding. + * illegal encodings by some "\xnn" and quote all control characters */ char * -utf8_to_native( const char *string ) +utf8_to_native( const char *string, size_t length ) { - #if 0 + int nleft; + int i; + byte encbuf[7]; + int encidx; const byte *s; size_t n; - byte *buffer, *p; - - /* quick check whether we actually have characters with bit 8 set */ - for( s=string; *s; s++ ) - if( *s & 0x80 ) - break; - if( !*s ) /* that is easy */ - return m_strdup(string); - - /* count the extended utf-8 characters */ - 110x xxxx - 1110 xxxx - 1111 0xxx - for( n=1, s=string; *s; s++ ) { - if( !(*s & 0x80) ) - n++; - else if( (*s & 0xe0) == 0xc0 ) - n += 2; - else if( (*s & 0xf0) == 0xe0 ) - n += 3; - else if( (*s & 0xf8) == 0xf0 ) - n += 4; - else - n++; /* invalid encoding */ - } + byte *buffer = NULL, *p = NULL; + unsigned long val = 0; + size_t slen; + int resync = 0; + + /* 1. pass (p==NULL): count the extended utf-8 characters */ + /* 2. pass (p!=NULL): create string */ + for( ;; ) { + for( slen=length, nleft=encidx=0, n=0, s=string; slen; s++, slen-- ) { + if( resync ) { + if( !(*s < 128 || (*s >= 0xc0 && *s <= 0xfd)) ) { + /* still invalid */ + if( p ) { + sprintf(p, "\\x%02x", *s ); + p += 4; + } + n += 4; + continue; + } + resync = 0; + } + if( !nleft ) { + if( !(*s & 0x80) ) { /* plain ascii */ + if( iscntrl( *s ) ) { + n++; + if( p ) + *p++ = '\\'; + switch( *s ) { + case '\n': n++; if( p ) *p++ = 'n'; break; + case '\r': n++; if( p ) *p++ = 'r'; break; + case '\f': n++; if( p ) *p++ = 'f'; break; + case '\v': n++; if( p ) *p++ = 'v'; break; + case '\b': n++; if( p ) *p++ = 'b'; break; + case 0 : n++; if( p ) *p++ = '0'; break; + default: n += 3; + sprintf( p, "x%02x", *s ); + p += 3; + break; + } + } + else { + if( p ) *p++ = *s; + n++; + } + } + else if( (*s & 0xe0) == 0xc0 ) { /* 110x xxxx */ + val = *s & 0x1f; + nleft = 1; + encbuf[encidx=0] = *s; + } + else if( (*s & 0xf0) == 0xe0 ) { /* 1110 xxxx */ + val = *s & 0x0f; + nleft = 2; + encbuf[encidx=0] = *s; + } + else if( (*s & 0xf8) == 0xf0 ) { /* 1111 0xxx */ + val = *s & 0x07; + nleft = 3; + encbuf[encidx=0] = *s; + } + else if( (*s & 0xfc) == 0xf8 ) { /* 1111 10xx */ + val = *s & 0x03; + nleft = 4; + encbuf[encidx=0] = *s; + } + else if( (*s & 0xfe) == 0xfc ) { /* 1111 110x */ + val = *s & 0x01; + nleft = 5; + encbuf[encidx=0] = *s; + } + else { /* invalid encoding: print as \xnn */ + if( p ) { + sprintf(p, "\\x%02x", *s ); + p += 4; + } + n += 4; + resync = 1; + } + } + else if( *s < 0x80 || *s >= 0xc0 ) { /* invalid */ + if( p ) { + sprintf(p, "\\x%02x", *s ); + p += 4; + } + n += 4; + nleft = 0; + resync = 1; + } + else { + encbuf[++encidx] = *s; + val <<= 6; + val |= *s & 0x3f; + if( !--nleft ) { /* ready */ + if( active_charset ) { /* table lookup */ + for(i=0; i < 128; i++ ) { + if( active_charset[i] == val ) + break; + } + if( i < 128 ) { /* we can print this one */ + if( p ) *p++ = i+128; + n++; + } + else { /* we do not have a translation: print utf8 */ + if( p ) { + for(i=0; i < encidx; i++ ) { + sprintf(p, "\\x%02x", encbuf[i] ); + p += 4; + } + } + n += encidx*4; + } + } + else { /* native set */ + if( val >= 0x80 && val < 256 ) { + n++; /* we can simply print this character */ + if( p ) *p++ = val; + } + else { /* we do not have a translation: print utf8 */ + if( p ) { + for(i=0; i < encidx; i++ ) { + sprintf(p, "\\x%02x", encbuf[i] ); + p += 4; + } + } + n += encidx*4; + } + } - buffer = p = m_alloc( n ); - for( s=string; *s; ) { - if( !(*s & 0x80) ) - *p++ = *s++; - else if( (*s & 0xe0) == 0xc0 ) { - u32 val; - if( (s[1] & 0xc0) != 0x80 ) - ; - val = (*s << 6) | (s[1] & 0x3f); + } + + } + } + if( !buffer ) { /* allocate the buffer after the first pass */ + buffer = p = m_alloc( n + 1 ); + } + else { + *p = 0; /* make a string */ + return buffer; } - else if( (*s & 0xf0) == 0xe0 ) - n += 3; - else if( (*s & 0xf8) == 0xf0 ) - n += 4; - else - n++; /* invalid encoding */ } - #endif - return m_strdup(string); - } -/**************** - * check whether string is a valid UTF8 string. - * Returns 0 = Okay - * 1 = Too short - * 2 = invalid encoding - */ -int -check_utf8_string( const char *string ) -{ - /*fixme */ - return 0; -} - /********************************************* ********** missing string functions ********* diff --git a/util/ttyio.c b/util/ttyio.c index 3f5eb7900..74f6ce0f6 100644 --- a/util/ttyio.c +++ b/util/ttyio.c @@ -235,6 +235,29 @@ tty_print_string( byte *p, size_t n ) #endif } +void +tty_print_utf8_string( byte *p, size_t n ) +{ + size_t i; + char *buf; + + if (no_terminal) + return; + + /* we can handle plain ascii simpler, so check for it first */ + for(i=0; i < n; i++ ) { + if( p[i] & 0x80 ) + break; + } + if( i < n ) { + buf = utf8_to_native( p, n ); + tty_printf("%s", buf ); + m_free( buf ); + } + else + tty_print_string( p, n ); +} + |