Skip to content

Commit 1543b98

Browse files
committed
* modules/ssl/ssl_engine_ocsp.c (extract_responder_uri): Use
modssl_ASN1_STRING_convert instead of directly accessing ASN1_STRING data pointer. * modules/ssl/ssl_util_ssl.c (modssl_ASN1_STRING_convert): Rename from asn1_string_convert and export function. (asn1_string_to_utf8): Update to use modssl_ASN1_STRING_convert. (modssl_X509_NAME_ENTRY_to_string): Update to use modssl_ASN1_STRING_convert. * modules/ssl/ssl_util_ssl.h (modssl_ASN1_STRING_convert): Declare new function.
1 parent 6be6fd2 commit 1543b98

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

modules/ssl/ssl_engine_ocsp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static const char *extract_responder_uri(X509 *cert, apr_pool_t *pool)
3838
/* Name found in extension, and is a URI: */
3939
if (OBJ_obj2nid(value->method) == NID_ad_OCSP
4040
&& value->location->type == GEN_URI) {
41-
result = apr_pstrdup(pool,
42-
(char *)value->location->d.uniformResourceIdentifier->data);
41+
const ASN1_STRING *uri = value->location->d.uniformResourceIdentifier;
42+
result = modssl_ASN1_STRING_convert(pool, uri, 0);
4343
}
4444
}
4545

modules/ssl/ssl_util_ssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ char *modssl_bio_free_read(apr_pool_t *p, BIO *bio)
206206
/* Convert ASN.1 string to a pool-allocated char * string, escaping
207207
* control characters. If raw is zero, convert to UTF-8, otherwise
208208
* unchanged from the character set. */
209-
static char *asn1_string_convert(apr_pool_t *p, const ASN1_STRING *asn1str, int raw)
209+
char *modssl_ASN1_STRING_convert(apr_pool_t *p, const ASN1_STRING *asn1str, int raw)
210210
{
211211
BIO *bio;
212212
int flags = ASN1_STRFLGS_ESC_CTRL;
@@ -221,13 +221,13 @@ static char *asn1_string_convert(apr_pool_t *p, const ASN1_STRING *asn1str, int
221221
return modssl_bio_free_read(p, bio);
222222
}
223223

224-
#define asn1_string_to_utf8(p, a) asn1_string_convert(p, a, 0)
224+
#define asn1_string_to_utf8(p, a) modssl_ASN1_STRING_convert(p, a, 0)
225225

226226
/* convert a NAME_ENTRY to UTF8 string */
227227
char *modssl_X509_NAME_ENTRY_to_string(apr_pool_t *p, const X509_NAME_ENTRY *xsne,
228228
int raw)
229229
{
230-
char *result = asn1_string_convert(p, X509_NAME_ENTRY_get_data(xsne), raw);
230+
char *result = modssl_ASN1_STRING_convert(p, X509_NAME_ENTRY_get_data(xsne), raw);
231231
ap_xlate_proto_from_ascii(result, len);
232232
return result;
233233
}

modules/ssl/ssl_util_ssl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ BOOL modssl_X509_getSAN(apr_pool_t *, X509 *, int, const char *, int, apr
7878
BOOL modssl_X509_match_name(apr_pool_t *, X509 *, const char *, BOOL, server_rec *);
7979
char *modssl_SSL_SESSION_id2sz(IDCONST unsigned char *, int, char *, int);
8080

81+
/* Convert ASN.1 string to a pool-allocated char * string, escaping
82+
* control characters. If raw is zero, convert to UTF-8, otherwise
83+
* unchanged from the character set. */
84+
char *modssl_ASN1_STRING_convert(apr_pool_t *p, const ASN1_STRING *asn1str,
85+
int raw);
86+
8187
/* Reads the remaining data in BIO, if not empty, and copies it into a
8288
* pool-allocated string. If empty, returns NULL. BIO_free(bio) is
8389
* called for both cases. */

0 commit comments

Comments
 (0)