summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/f_string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/f_string.c')
-rw-r--r--src/lib/libcrypto/asn1/f_string.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c
index ab2837824e..968698a798 100644
--- a/src/lib/libcrypto/asn1/f_string.c
+++ b/src/lib/libcrypto/asn1/f_string.c
@@ -58,16 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "buffer.h" 61#include <openssl/buffer.h>
62#include "x509.h" 62#include <openssl/asn1.h>
63 63
64int i2a_ASN1_STRING(bp, a, type) 64int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type)
65BIO *bp;
66ASN1_STRING *a;
67int type;
68 { 65 {
69 int i,n=0; 66 int i,n=0;
70 static char *h="0123456789ABCDEF"; 67 static const char *h="0123456789ABCDEF";
71 char buf[2]; 68 char buf[2];
72 69
73 if (a == NULL) return(0); 70 if (a == NULL) return(0);
@@ -97,11 +94,7 @@ err:
97 return(-1); 94 return(-1);
98 } 95 }
99 96
100int a2i_ASN1_STRING(bp,bs,buf,size) 97int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
101BIO *bp;
102ASN1_STRING *bs;
103char *buf;
104int size;
105 { 98 {
106 int ret=0; 99 int ret=0;
107 int i,j,k,m,n,again,bufsize; 100 int i,j,k,m,n,again,bufsize;
@@ -130,9 +123,18 @@ int size;
130 123
131 for (j=i-1; j>0; j--) 124 for (j=i-1; j>0; j--)
132 { 125 {
126#ifndef CHARSET_EBCDIC
133 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) || 127 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) ||
134 ((buf[j] >= 'a') && (buf[j] <= 'f')) || 128 ((buf[j] >= 'a') && (buf[j] <= 'f')) ||
135 ((buf[j] >= 'A') && (buf[j] <= 'F')))) 129 ((buf[j] >= 'A') && (buf[j] <= 'F'))))
130#else
131 /* This #ifdef is not strictly necessary, since
132 * the characters A...F a...f 0...9 are contiguous
133 * (yes, even in EBCDIC - but not the whole alphabet).
134 * Nevertheless, isxdigit() is faster.
135 */
136 if (!isxdigit(buf[j]))
137#endif
136 { 138 {
137 i=j; 139 i=j;
138 break; 140 break;
@@ -156,15 +158,15 @@ int size;
156 if (num+i > slen) 158 if (num+i > slen)
157 { 159 {
158 if (s == NULL) 160 if (s == NULL)
159 sp=(unsigned char *)Malloc( 161 sp=(unsigned char *)OPENSSL_malloc(
160 (unsigned int)num+i*2); 162 (unsigned int)num+i*2);
161 else 163 else
162 sp=(unsigned char *)Realloc(s, 164 sp=(unsigned char *)OPENSSL_realloc(s,
163 (unsigned int)num+i*2); 165 (unsigned int)num+i*2);
164 if (sp == NULL) 166 if (sp == NULL)
165 { 167 {
166 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE); 168 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);
167 if (s != NULL) Free((char *)s); 169 if (s != NULL) OPENSSL_free(s);
168 goto err; 170 goto err;
169 } 171 }
170 s=sp; 172 s=sp;