From 72cf93388c0aedc50e66dc2ece236a919d4eaf42 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 2 Jul 2009 13:40:15 +0000 Subject: Minor bug fixes. --- THANKS | 2 ++ cipher/ChangeLog | 5 +++++ cipher/md.c | 11 +++++++---- src/ChangeLog | 10 ++++++++++ src/dumpsexp.c | 39 ++++++++++++++++++++++++++++++++------- src/sexp.c | 1 - tests/ChangeLog | 4 ++++ tests/benchmark.c | 12 ++++++------ 8 files changed, 66 insertions(+), 18 deletions(-) diff --git a/THANKS b/THANKS index 84626089..856bac6a 100644 --- a/THANKS +++ b/THANKS @@ -21,6 +21,7 @@ Christian Grothoff grothoff@cs.purdue.edu Christian von Roques roques@pond.sub.org Christopher Oliver oliver@fritz.traverse.net Christian Recktenwald chris@citecs.de +Daiki Ueno ueno at unixuser org Dan Fandrich dan at coneharvesters com Daniel Eisenbud eisenbud@cs.swarthmore.edu Daniel Koening dan@mail.isis.de @@ -32,6 +33,7 @@ Ed Boraas ecxjo@esperanto.org Elie De Brauwer elie@de-brauwer.be Enzo Michelangeli em@MailAndNews.com Ernst Molitor ernst.molitor@uni-bonn.de +Fabian Keil fk at fabiankeil de Fabio Coatti cova@felix.unife.it Felix von Leitner leitner@amdiv.de Frank Heckenbach heckenb@mi.uni-erlangen.de diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 27f686a3..d4e7bf8d 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,8 @@ +2009-07-02 Werner Koch + + * md.c (md_read): Fix incomplete check for NULL. + Reported by Fabian Kail. + 2009-03-31 Werner Koch * rsa.c (rsa_check_secret_key): Return GPG_ERR_BAD_SECKEY and not diff --git a/cipher/md.c b/cipher/md.c index 5dfbbd95..9528f6d3 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -948,10 +948,13 @@ md_read( gcry_md_hd_t a, int algo ) if (! algo) { - /* return the first algorithm */ - if (r && r->next) - log_debug ("more than one algorithm in md_read(0)\n"); - return r->digest->read( &r->context.c ); + /* Return the first algorithm */ + if (r) + { + if (r->next) + log_debug ("more than one algorithm in md_read(0)\n"); + return r->digest->read (&r->context.c); + } } else { diff --git a/src/ChangeLog b/src/ChangeLog index 1b784e4d..94cc4be9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2009-07-02 Werner Koch + + * dumpsexp.c (main): Fix handling multiple files. + (parse_and_print): Implement hex and octal escaping. + + * sexp.c (unquote_string): Remove superfluous clearing of ESC. + * dumpsexp.c (parse_and_print): Add missing break. + (main): Fix return value. + Reported by Fabian Keil. + 2009-02-16 Werner Koch * ath.h [HAVE_SYS_SELECT_H]: Include for fd_set. diff --git a/src/dumpsexp.c b/src/dumpsexp.c index 8f5c0d30..0e64c8b5 100644 --- a/src/dumpsexp.c +++ b/src/dumpsexp.c @@ -276,7 +276,7 @@ printhex (int c) - +/* Returns 0 on success. */ static int parse_and_print (FILE *fp) { @@ -488,12 +488,37 @@ parse_and_print (FILE *fp) state = IN_STRING; break; } + break; case IN_OCT_ESC: - state = IN_STRING; + if (quote_idx < 3 && strchr ("01234567", c)) + { + quote_buf[quote_idx++] = c; + if (quote_idx == 3) + { + printchr ((unsigned int)quote_buf[0] * 8 * 8 + + (unsigned int)quote_buf[1] * 8 + + (unsigned int)quote_buf[2]); + state = IN_STRING; + } + } + else + state = IN_STRING; break; case IN_HEX_ESC: - state = IN_STRING; + if (quote_idx < 2 && strchr ("0123456789abcdefABCDEF", c)) + { + quote_buf[quote_idx++] = c; + if (quote_idx == 2) + { + printchr (xtoi_1 (quote_buf[0]) * 16 + + xtoi_1 (quote_buf[1])); + + state = IN_STRING; + } + } + else + state = IN_STRING; break; case CR_ESC: state = IN_STRING; @@ -590,7 +615,8 @@ main (int argc, char **argv) } else { - for (; argc; argc--) + rc = 0; + for (; argc; argv++, argc--) { FILE *fp = fopen (*argv, "rb"); if (!fp) @@ -600,14 +626,13 @@ main (int argc, char **argv) } else { - if ( parse_and_print (fp) ) + if (parse_and_print (fp)) rc = 1; fclose (fp); } } } - - return !rc; + return !!rc; } diff --git a/src/sexp.c b/src/sexp.c index 81500b1a..77825ba0 100644 --- a/src/sexp.c +++ b/src/sexp.c @@ -909,7 +909,6 @@ unquote_string (const char *string, size_t length, unsigned char *buf) { s++; n--; } - esc = 0; break; case '\n': /* ignore LF[,CR] */ diff --git a/tests/ChangeLog b/tests/ChangeLog index 4ff10a87..55b8e9ab 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2009-06-08 Werner Koch + + * benchmark.c (cipher_bench): Center labels. Suggested by Brad Hards. + 2009-02-16 Werner Koch * fipsdrv.c (print_buffer): Remove parens from initializer for diff --git a/tests/benchmark.c b/tests/benchmark.c index 8f8f04ce..07509ae8 100644 --- a/tests/benchmark.c +++ b/tests/benchmark.c @@ -448,12 +448,12 @@ cipher_bench ( const char *algoname ) size_t allocated_buflen, buflen; int repetitions; static struct { int mode; const char *name; int blocked; } modes[] = { - { GCRY_CIPHER_MODE_ECB, "ECB", 1 }, - { GCRY_CIPHER_MODE_CBC, "CBC", 1 }, - { GCRY_CIPHER_MODE_CFB, "CFB", 0 }, - { GCRY_CIPHER_MODE_OFB, "OFB", 0 }, - { GCRY_CIPHER_MODE_CTR, "CTR", 0 }, - { GCRY_CIPHER_MODE_STREAM, "STREAM", 0 }, + { GCRY_CIPHER_MODE_ECB, " ECB", 1 }, + { GCRY_CIPHER_MODE_CBC, " CBC", 1 }, + { GCRY_CIPHER_MODE_CFB, " CFB", 0 }, + { GCRY_CIPHER_MODE_OFB, " OFB", 0 }, + { GCRY_CIPHER_MODE_CTR, " CTR", 0 }, + { GCRY_CIPHER_MODE_STREAM, " STREAM", 0 }, {0} }; int modeidx; -- cgit v1.2.1