diff options
| author | markus <> | 2002-09-05 12:51:50 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 12:51:50 +0000 |
| commit | 15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch) | |
| tree | bf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/asn1/f_string.c | |
| parent | 027351f729b9e837200dae6e1520cda6577ab930 (diff) | |
| download | openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2 openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip | |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/asn1/f_string.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/f_string.c | 32 |
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 | ||
| 64 | int i2a_ASN1_STRING(bp, a, type) | 64 | int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type) |
| 65 | BIO *bp; | ||
| 66 | ASN1_STRING *a; | ||
| 67 | int 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 | ||
| 100 | int a2i_ASN1_STRING(bp,bs,buf,size) | 97 | int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) |
| 101 | BIO *bp; | ||
| 102 | ASN1_STRING *bs; | ||
| 103 | char *buf; | ||
| 104 | int 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; |
