Some constification and stacks that slipped through the cracks (how?).
[openssl.git] / crypto / asn1 / a_print.c
index babb571c5ba72be1a450deda6774f294128c2fef..cdec7a1561d873c99729b308f0cec80c185f1e28 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "asn1.h"
-
-/* ASN1err(ASN1_F_D2I_ASN1_PRINT_TYPE,ASN1_R_WRONG_PRINTABLE_TYPE);
- * ASN1err(ASN1_F_D2I_ASN1_PRINT_TYPE,ASN1_R_TAG_VALUE_TOO_HIGH);
- */
+#include <openssl/asn1.h>
 
 int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp)
        { return(M_i2d_ASN1_IA5STRING(a,pp)); }
@@ -99,6 +95,7 @@ int ASN1_PRINTABLE_type(unsigned char *s, int len)
        while ((*s) && (len-- != 0))
                {
                c= *(s++);
+#ifndef CHARSET_EBCDIC
                if (!(  ((c >= 'a') && (c <= 'z')) ||
                        ((c >= 'A') && (c <= 'Z')) ||
                        (c == ' ') ||
@@ -112,6 +109,13 @@ int ASN1_PRINTABLE_type(unsigned char *s, int len)
                        ia5=1;
                if (c&0x80)
                        t61=1;
+#else
+               if (!isalnum(c) && (c != ' ') &&
+                   strchr("'()+,-./:=?", c) == NULL)
+                       ia5=1;
+               if (os_toascii[c] & 0x80)
+                       t61=1;
+#endif
                }
        if (t61) return(V_ASN1_T61STRING);
        if (ia5) return(V_ASN1_IA5STRING);