From 2ca9bdb39bcc510295b1af0fffcf2cd183bdb2bb Mon Sep 17 00:00:00 2001 From: Kaspar Brand Date: Sun, 8 Jan 2012 10:12:18 +0000 Subject: [PATCH] merge r1228816 from trunk: fix signedness issue with SSL_X509_NAME_to_string()'s maxlen argument git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1228817 13f79535-47bb-0310-9956-ffa450edef68 --- modules/ssl/ssl_util_ssl.c | 6 +++--- modules/ssl/ssl_util_ssl.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ssl/ssl_util_ssl.c b/modules/ssl/ssl_util_ssl.c index d5b89ef2a7..13362bee29 100644 --- a/modules/ssl/ssl_util_ssl.c +++ b/modules/ssl/ssl_util_ssl.c @@ -260,7 +260,7 @@ char *SSL_X509_NAME_ENTRY_to_string(apr_pool_t *p, X509_NAME_ENTRY *xsne) * convert an X509_NAME to an RFC 2253 formatted string, optionally truncated * to maxlen characters (specify a maxlen of 0 for no length limit) */ -char *SSL_X509_NAME_to_string(apr_pool_t *p, X509_NAME *dn, unsigned int maxlen) +char *SSL_X509_NAME_to_string(apr_pool_t *p, X509_NAME *dn, int maxlen) { char *result = NULL; BIO *bio; @@ -271,8 +271,8 @@ char *SSL_X509_NAME_to_string(apr_pool_t *p, X509_NAME *dn, unsigned int maxlen) X509_NAME_print_ex(bio, dn, 0, XN_FLAG_RFC2253); len = BIO_pending(bio); if (len > 0) { - result = apr_palloc(p, maxlen ? maxlen+1 : len+1); - if (maxlen && maxlen < len) { + result = apr_palloc(p, (maxlen > 0) ? maxlen+1 : len+1); + if (maxlen > 0 && maxlen < len) { len = BIO_read(bio, result, maxlen); if (maxlen > 2) { /* insert trailing ellipsis if there's enough space */ diff --git a/modules/ssl/ssl_util_ssl.h b/modules/ssl/ssl_util_ssl.h index 6eaa137436..1688bb6706 100644 --- a/modules/ssl/ssl_util_ssl.h +++ b/modules/ssl/ssl_util_ssl.h @@ -66,7 +66,7 @@ int SSL_smart_shutdown(SSL *ssl); BOOL SSL_X509_isSGC(X509 *); BOOL SSL_X509_getBC(X509 *, int *, int *); char *SSL_X509_NAME_ENTRY_to_string(apr_pool_t *p, X509_NAME_ENTRY *xsne); -char *SSL_X509_NAME_to_string(apr_pool_t *, X509_NAME *, unsigned int); +char *SSL_X509_NAME_to_string(apr_pool_t *, X509_NAME *, int); BOOL SSL_X509_getIDs(apr_pool_t *, X509 *, apr_array_header_t **); BOOL SSL_X509_INFO_load_file(apr_pool_t *, STACK_OF(X509_INFO) *, const char *); BOOL SSL_X509_INFO_load_path(apr_pool_t *, STACK_OF(X509_INFO) *, const char *); -- 2.40.0