[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Fri Apr 29 14:06:17 UTC 2016


The branch master has been updated
       via  a1f41284d7eb3c72096ae9cbd6a0673c0bb0d267 (commit)
       via  a1f82f06399f6c3cbee2009a498f4e7e620b2330 (commit)
       via  97a982e2eee2e04e8e41ae12665af417315a0f23 (commit)
       via  4cd5c3f4eef81c791a5041dc17ec27aa08540e42 (commit)
       via  e31066f7e9894c9cdaef80404da854f89e9e365f (commit)
       via  5fd1478df34be8d17c8507f17ec4298635c72814 (commit)
      from  e590afdcf41c63255d6393a3299c71fdb4813d66 (commit)


- Log -----------------------------------------------------------------
commit a1f41284d7eb3c72096ae9cbd6a0673c0bb0d267
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Apr 29 14:46:07 2016 +0100

    Misc tweaks for EBCDIC based on feedback received
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit a1f82f06399f6c3cbee2009a498f4e7e620b2330
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Apr 29 11:03:00 2016 +0100

    Fix EBCDIC problem in conf_def.h
    
    The non-ascii version of this set of macros ensures that the "a" variable
    is inside the expected range. This logic wasn't quite right for the
    EBCDIC version.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit 97a982e2eee2e04e8e41ae12665af417315a0f23
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Apr 29 10:56:20 2016 +0100

    Fix the tests to work with EBCDIC
    
    Most of the tests already pass with EBCIDC but a few were trying to
    write into read only memory.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit 4cd5c3f4eef81c791a5041dc17ec27aa08540e42
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Apr 29 10:30:05 2016 +0100

    Fix a build error with strict-warnings and CHARSET_EBCDIC
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit e31066f7e9894c9cdaef80404da854f89e9e365f
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Apr 29 10:19:27 2016 +0100

    Add the ability to test EBCDIC builds
    
    This adds the define CHARSET_EBCDIC_TEST which enables testing of EBCDIC
    code on an ASCII system.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit 5fd1478df34be8d17c8507f17ec4298635c72814
Author: Matt Caswell <matt at openssl.org>
Date:   Thu Apr 28 11:34:54 2016 +0100

    Fix building with -DCHARSET_EBCDIC
    
    Building with -DCHARSET_EBCDIC and using --strict-warnings resulted in
    lots of miscellaneous errors. This fixes it.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 apps/s_server.c        | 93 +++++++++++++++++++++++++++++---------------------
 crypto/asn1/a_print.c  |  1 +
 crypto/asn1/f_int.c    |  1 +
 crypto/asn1/f_string.c |  1 +
 crypto/conf/conf_def.h | 22 ++++++------
 crypto/ebcdic.c        | 82 ++++++++++++++++++++++++++++++++++++++++++--
 crypto/x509/x509_obj.c |  6 ++--
 ssl/ssl_ciph.c         |  1 +
 test/bftest.c          |  2 +-
 test/mdc2test.c        |  2 +-
 test/rmdtest.c         | 38 +++++++++------------
 test/sha1test.c        | 32 +++++++----------
 12 files changed, 184 insertions(+), 97 deletions(-)

diff --git a/apps/s_server.c b/apps/s_server.c
index 6c8541e..f0b28fd 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -181,6 +181,9 @@ typedef unsigned int u_int;
 #endif
 #include "s_apps.h"
 #include "timeouts.h"
+#ifdef CHARSET_EBCDIC
+#include <openssl/ebcdic.h>
+#endif
 
 static int not_resumable_sess_cb(SSL *s, int is_forward_secure);
 static int sv_body(int s, int stype, unsigned char *context);
@@ -420,17 +423,7 @@ static int ebcdic_gets(BIO *bp, char *buf, int size);
 static int ebcdic_puts(BIO *bp, const char *str);
 
 # define BIO_TYPE_EBCDIC_FILTER  (18|0x0200)
-static const BIO_METHOD methods_ebcdic = {
-    BIO_TYPE_EBCDIC_FILTER,
-    "EBCDIC/ASCII filter",
-    ebcdic_write,
-    ebcdic_read,
-    ebcdic_puts,
-    ebcdic_gets,
-    ebcdic_ctrl,
-    ebcdic_new,
-    ebcdic_free,
-};
+static BIO_METHOD *methods_ebcdic = NULL;
 
 /* This struct is "unwarranted chumminess with the compiler." */
 typedef struct {
@@ -438,9 +431,22 @@ typedef struct {
     char buff[1];
 } EBCDIC_OUTBUFF;
 
-const BIO_METHOD *BIO_f_ebcdic_filter()
+static const BIO_METHOD *BIO_f_ebcdic_filter()
 {
-    return (&methods_ebcdic);
+    if (methods_ebcdic == NULL) {
+        methods_ebcdic = BIO_meth_new(BIO_TYPE_EBCDIC_FILTER,
+            "EBCDIC/ASCII filter");
+        if (   methods_ebcdic == NULL
+            || !BIO_meth_set_write(methods_ebcdic, ebcdic_write)
+            || !BIO_meth_set_read(methods_ebcdic, ebcdic_read)
+            || !BIO_meth_set_puts(methods_ebcdic, ebcdic_puts)
+            || !BIO_meth_set_gets(methods_ebcdic, ebcdic_gets)
+            || !BIO_meth_set_ctrl(methods_ebcdic, ebcdic_ctrl)
+            || !BIO_meth_set_create(methods_ebcdic, ebcdic_new)
+            || !BIO_meth_set_destroy(methods_ebcdic, ebcdic_free))
+            return NULL;
+    }
+    return methods_ebcdic;
 }
 
 static int ebcdic_new(BIO *bi)
@@ -451,68 +457,71 @@ static int ebcdic_new(BIO *bi)
     wbuf->alloced = 1024;
     wbuf->buff[0] = '\0';
 
-    bi->ptr = (char *)wbuf;
-    bi->init = 1;
-    bi->flags = 0;
-    return (1);
+    BIO_set_data(bi, wbuf);
+    BIO_set_init(bi, 1);
+    return 1;
 }
 
 static int ebcdic_free(BIO *a)
 {
+    EBCDIC_OUTBUFF *wbuf;
+
     if (a == NULL)
-        return (0);
-    OPENSSL_free(a->ptr);
-    a->ptr = NULL;
-    a->init = 0;
-    a->flags = 0;
-    return (1);
+        return 0;
+    wbuf = BIO_get_data(a);
+    OPENSSL_free(wbuf);
+    BIO_set_data(a, NULL);
+    BIO_set_init(a, 0);
+
+    return 1;
 }
 
 static int ebcdic_read(BIO *b, char *out, int outl)
 {
     int ret = 0;
+    BIO *next = BIO_next(b);
 
     if (out == NULL || outl == 0)
         return (0);
-    if (b->next_bio == NULL)
+    if (next == NULL)
         return (0);
 
-    ret = BIO_read(b->next_bio, out, outl);
+    ret = BIO_read(next, out, outl);
     if (ret > 0)
         ascii2ebcdic(out, out, ret);
-    return (ret);
+    return ret;
 }
 
 static int ebcdic_write(BIO *b, const char *in, int inl)
 {
     EBCDIC_OUTBUFF *wbuf;
+    BIO *next = BIO_next(b);
     int ret = 0;
     int num;
-    unsigned char n;
 
     if ((in == NULL) || (inl <= 0))
         return (0);
-    if (b->next_bio == NULL)
-        return (0);
+    if (next == NULL)
+        return 0;
 
-    wbuf = (EBCDIC_OUTBUFF *) b->ptr;
+    wbuf = (EBCDIC_OUTBUFF *) BIO_get_data(b);
 
     if (inl > (num = wbuf->alloced)) {
         num = num + num;        /* double the size */
         if (num < inl)
             num = inl;
+        OPENSSL_free(wbuf);
         wbuf = app_malloc(sizeof(*wbuf) + num, "grow ebcdic wbuf");
-        OPENSSL_free(b->ptr);
 
         wbuf->alloced = num;
         wbuf->buff[0] = '\0';
 
-        b->ptr = (char *)wbuf;
+        BIO_set_data(b, wbuf);
     }
 
     ebcdic2ascii(wbuf->buff, in, inl);
 
-    ret = BIO_write(b->next_bio, wbuf->buff, inl);
+    ret = BIO_write(next, wbuf->buff, inl);
 
     return (ret);
 }
@@ -520,15 +529,16 @@ static int ebcdic_write(BIO *b, const char *in, int inl)
 static long ebcdic_ctrl(BIO *b, int cmd, long num, void *ptr)
 {
     long ret;
+    BIO *next = BIO_next(b);
 
-    if (b->next_bio == NULL)
+    if (next == NULL)
         return (0);
     switch (cmd) {
     case BIO_CTRL_DUP:
         ret = 0L;
         break;
     default:
-        ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
+        ret = BIO_ctrl(next, cmd, num, ptr);
         break;
     }
     return (ret);
@@ -537,8 +547,10 @@ static long ebcdic_ctrl(BIO *b, int cmd, long num, void *ptr)
 static int ebcdic_gets(BIO *bp, char *buf, int size)
 {
     int i, ret = 0;
-    if (bp->next_bio == NULL)
-        return (0);
+    BIO *next = BIO_next(bp);
+
+    if (next == NULL)
+        return 0;
 /*      return(BIO_gets(bp->next_bio,buf,size));*/
     for (i = 0; i < size - 1; ++i) {
         ret = ebcdic_read(bp, &buf[i], 1);
@@ -556,8 +568,8 @@ static int ebcdic_gets(BIO *bp, char *buf, int size)
 
 static int ebcdic_puts(BIO *bp, const char *str)
 {
-    if (bp->next_bio == NULL)
-        return (0);
+    if (BIO_next(bp) == NULL)
+        return 0;
     return ebcdic_write(bp, str, strlen(str));
 }
 #endif
@@ -2079,6 +2091,9 @@ int s_server_main(int argc, char *argv[])
     bio_s_out = NULL;
     BIO_free(bio_s_msg);
     bio_s_msg = NULL;
+#ifdef CHARSET_EBCDIC
+    BIO_meth_free(methods_ebcdic);
+#endif
     return (ret);
 }
 
diff --git a/crypto/asn1/a_print.c b/crypto/asn1/a_print.c
index 9c70891..cd65bb1 100644
--- a/crypto/asn1/a_print.c
+++ b/crypto/asn1/a_print.c
@@ -56,6 +56,7 @@
  */
 
 #include <stdio.h>
+#include <ctype.h>
 #include "internal/cryptlib.h"
 #include <openssl/asn1.h>
 
diff --git a/crypto/asn1/f_int.c b/crypto/asn1/f_int.c
index 0feb7a1..e0e49de 100644
--- a/crypto/asn1/f_int.c
+++ b/crypto/asn1/f_int.c
@@ -56,6 +56,7 @@
  */
 
 #include <stdio.h>
+#include <ctype.h>
 #include "internal/cryptlib.h"
 #include <openssl/buffer.h>
 #include <openssl/asn1.h>
diff --git a/crypto/asn1/f_string.c b/crypto/asn1/f_string.c
index 7d9eb14..2b2b545 100644
--- a/crypto/asn1/f_string.c
+++ b/crypto/asn1/f_string.c
@@ -56,6 +56,7 @@
  */
 
 #include <stdio.h>
+#include <ctype.h>
 #include "internal/cryptlib.h"
 #include <openssl/buffer.h>
 #include <openssl/asn1.h>
diff --git a/crypto/conf/conf_def.h b/crypto/conf/conf_def.h
index 3ebb0f7..7613593 100644
--- a/crypto/conf/conf_def.h
+++ b/crypto/conf/conf_def.h
@@ -95,18 +95,18 @@
 
 #else                           /* CHARSET_EBCDIC */
 
-# define IS_COMMENT(c,a)         (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT)
-# define IS_FCOMMENT(c,a)        (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT)
-# define IS_EOF(c,a)             (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF)
-# define IS_ESC(c,a)             (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC)
-# define IS_NUMBER(c,a)          (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER)
-# define IS_WS(c,a)              (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS)
-# define IS_ALPHA_NUMERIC(c,a)   (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC)
+# define IS_COMMENT(c,a)         (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_COMMENT)
+# define IS_FCOMMENT(c,a)        (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_FCOMMENT)
+# define IS_EOF(c,a)             (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_EOF)
+# define IS_ESC(c,a)             (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ESC)
+# define IS_NUMBER(c,a)          (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_NUMBER)
+# define IS_WS(c,a)              (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_WS)
+# define IS_ALPHA_NUMERIC(c,a)   (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ALPHA_NUMERIC)
 # define IS_ALPHA_NUMERIC_PUNCT(c,a) \
-                                (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
-# define IS_QUOTE(c,a)           (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE)
-# define IS_DQUOTE(c,a)          (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE)
-# define IS_HIGHBIT(c,a)         (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT)
+                                (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ALPHA_NUMERIC_PUNCT)
+# define IS_QUOTE(c,a)           (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_QUOTE)
+# define IS_DQUOTE(c,a)          (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_DQUOTE)
+# define IS_HIGHBIT(c,a)         (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_HIGHBIT)
 #endif                          /* CHARSET_EBCDIC */
 
 static const unsigned short CONF_type_default[256] = {
diff --git a/crypto/ebcdic.c b/crypto/ebcdic.c
index 1248cba..d662998 100644
--- a/crypto/ebcdic.c
+++ b/crypto/ebcdic.c
@@ -4,14 +4,92 @@
 NON_EMPTY_TRANSLATION_UNIT
 #else
 
-# include "ebcdic.h"
+# include <openssl/ebcdic.h>
 
 /*-
  *      Initial Port for  Apache-1.3     by <Martin.Kraemer at Mch.SNI.De>
  *      Adapted for       OpenSSL-0.9.4  by <Martin.Kraemer at Mch.SNI.De>
  */
 
-# ifdef _OSD_POSIX
+# ifdef CHARSET_EBCDIC_TEST
+/*
+ * Here we're looking to test the EBCDIC code on an ASCII system so we don't do
+ * any translation in these tables at all.
+ */
+
+/* The ebcdic-to-ascii table: */
+const unsigned char os_toascii[256] = {
+    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+    0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+    0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+    0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+    0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+    0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+    0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+    0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+    0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+    0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+    0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+    0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+    0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+    0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+    0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+    0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+    0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+    0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+    0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+    0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+};
+
+/* The ascii-to-ebcdic table: */
+const unsigned char os_toebcdic[256] = {
+    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+    0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+    0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+    0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+    0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+    0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+    0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+    0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+    0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+    0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+    0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+    0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+    0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+    0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+    0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+    0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+    0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+    0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+    0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+    0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+};
+
+# elif defined(_OSD_POSIX)
 /*
  * "BS2000 OSD" is a POSIX subsystem on a main frame. It is made by Siemens
  * AG, Germany, for their BS2000 mainframe machines. Within the POSIX
diff --git a/crypto/x509/x509_obj.c b/crypto/x509/x509_obj.c
index 8b4d436..ac871b4 100644
--- a/crypto/x509/x509_obj.c
+++ b/crypto/x509/x509_obj.c
@@ -76,7 +76,7 @@ char *X509_NAME_oneline(X509_NAME *a, char *buf, int len)
     int gs_doit[4];
     char tmp_buf[80];
 #ifdef CHARSET_EBCDIC
-    char ebcdic_buf[1024];
+    unsigned char ebcdic_buf[1024];
 #endif
 
     if (buf == NULL) {
@@ -117,8 +117,8 @@ char *X509_NAME_oneline(X509_NAME *a, char *buf, int len)
             type == V_ASN1_PRINTABLESTRING ||
             type == V_ASN1_TELETEXSTRING ||
             type == V_ASN1_VISIBLESTRING || type == V_ASN1_IA5STRING) {
-            ascii2ebcdic(ebcdic_buf, q, (num > sizeof ebcdic_buf)
-                         ? sizeof ebcdic_buf : num);
+            ascii2ebcdic(ebcdic_buf, q, (num > (int)sizeof(ebcdic_buf))
+                         ? (int)sizeof(ebcdic_buf) : num);
             q = ebcdic_buf;
         }
 #endif
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index d0d9d88..8b65daa 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -140,6 +140,7 @@
  */
 
 #include <stdio.h>
+#include <ctype.h>
 #include <openssl/objects.h>
 #include <openssl/comp.h>
 #include <openssl/engine.h>
diff --git a/test/bftest.c b/test/bftest.c
index b5e6c51..eb6ab3b 100644
--- a/test/bftest.c
+++ b/test/bftest.c
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
 #  include <openssl/ebcdic.h>
 # endif
 
-static char *bf_key[2] = {
+static char bf_key[2][30] = {
     "abcdefghijklmnopqrstuvwxyz",
     "Who is John Galt?"
 };
diff --git a/test/mdc2test.c b/test/mdc2test.c
index 2177a0e..e01a2a7 100644
--- a/test/mdc2test.c
+++ b/test/mdc2test.c
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
     unsigned char md[MDC2_DIGEST_LENGTH];
     int i;
     EVP_MD_CTX *c;
-    static char *text = "Now is the time for all ";
+    static char text[] = "Now is the time for all ";
 
 # ifdef CHARSET_EBCDIC
     ebcdic2ascii(text, text, strlen(text));
diff --git a/test/rmdtest.c b/test/rmdtest.c
index 867a20e..b5ed73d 100644
--- a/test/rmdtest.c
+++ b/test/rmdtest.c
@@ -75,16 +75,15 @@ int main(int argc, char *argv[])
 #  include <openssl/ebcdic.h>
 # endif
 
-static char *test[] = {
-    "",
-    "a",
-    "abc",
-    "message digest",
-    "abcdefghijklmnopqrstuvwxyz",
-    "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
-    "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
-    NULL,
+static char test[][100] = {
+    { "" },
+    { "a" },
+    { "abc" },
+    { "message digest" },
+    { "abcdefghijklmnopqrstuvwxyz" },
+    { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
+    { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
+    { "12345678901234567890123456789012345678901234567890123456789012345678901234567890" }
 };
 
 static char *ret[] = {
@@ -101,30 +100,27 @@ static char *ret[] = {
 static char *pt(unsigned char *md);
 int main(int argc, char *argv[])
 {
-    int i, err = 0;
-    char **P, **R;
+    unsigned int i;
+    int err = 0;
+    char **R;
     char *p;
     unsigned char md[RIPEMD160_DIGEST_LENGTH];
 
-    P = test;
     R = ret;
-    i = 1;
-    while (*P != NULL) {
+    for (i = 0; i < OSSL_NELEM(test); i++) {
 # ifdef CHARSET_EBCDIC
-        ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P));
+        ebcdic2ascii(test[i], test[i], strlen(test[i]));
 # endif
-        EVP_Digest(&(P[0][0]), strlen((char *)*P), md, NULL, EVP_ripemd160(),
+        EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_ripemd160(),
                    NULL);
         p = pt(md);
         if (strcmp(p, (char *)*R) != 0) {
-            printf("error calculating RIPEMD160 on '%s'\n", *P);
+            printf("error calculating RIPEMD160 on '%s'\n", test[i]);
             printf("got %s instead of %s\n", p, *R);
             err++;
         } else
-            printf("test %d ok\n", i);
-        i++;
+            printf("test %d ok\n", i + 1);
         R++;
-        P++;
     }
     EXIT(err);
 }
diff --git a/test/sha1test.c b/test/sha1test.c
index ada37d1..3e9104a 100644
--- a/test/sha1test.c
+++ b/test/sha1test.c
@@ -67,10 +67,9 @@
 # include <openssl/ebcdic.h>
 #endif
 
-static char *test[] = {
-    "abc",
-    "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-    NULL,
+static char test[][80] = {
+    { "abc" },
+    { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }
 };
 
 static char *ret[] = {
@@ -83,34 +82,29 @@ static char *bigret = "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
 static char *pt(unsigned char *md);
 int main(int argc, char *argv[])
 {
-    int i, err = 0;
-    char **P, **R;
+    unsigned int i;
+    int err = 0;
+    char **R;
     static unsigned char buf[1000];
     char *p, *r;
     EVP_MD_CTX *c;
     unsigned char md[SHA_DIGEST_LENGTH];
 
-#ifdef CHARSET_EBCDIC
-    ebcdic2ascii(test[0], test[0], strlen(test[0]));
-    ebcdic2ascii(test[1], test[1], strlen(test[1]));
-#endif
-
     c = EVP_MD_CTX_new();
-    P = test;
     R = ret;
-    i = 1;
-    while (*P != NULL) {
-        EVP_Digest(*P, strlen((char *)*P), md, NULL, EVP_sha1(), NULL);
+    for (i = 0; i < OSSL_NELEM(test); i++) {
+# ifdef CHARSET_EBCDIC
+        ebcdic2ascii(test[i], test[i], strlen(test[i]));
+# endif
+        EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_sha1(), NULL);
         p = pt(md);
         if (strcmp(p, (char *)*R) != 0) {
-            printf("error calculating SHA1 on '%s'\n", *P);
+            printf("error calculating SHA1 on '%s'\n", test[i]);
             printf("got %s instead of %s\n", p, *R);
             err++;
         } else
-            printf("test %d ok\n", i);
-        i++;
+            printf("test %d ok\n", i + 1);
         R++;
-        P++;
     }
 
     memset(buf, 'a', 1000);


More information about the openssl-commits mailing list