summaryrefslogtreecommitdiffstats
path: root/modules/ssl
diff options
context:
space:
mode:
authorChristophe Jaillet <jailletc36@apache.org>2013-01-06 18:40:13 +0100
committerChristophe Jaillet <jailletc36@apache.org>2013-01-06 18:40:13 +0100
commitf77c0f880510057e24a6e5aa47aefda37d4ba6f8 (patch)
tree6fc73d7778f1533d8acfaa8b64415fc16ec2d07b /modules/ssl
parentUpdates. (diff)
downloadapache2-f77c0f880510057e24a6e5aa47aefda37d4ba6f8.tar.xz
apache2-f77c0f880510057e24a6e5aa47aefda37d4ba6f8.zip
According top my testing 'SSL_SESSION_id2sz' is 4x faster with the use 'ap_bin2hex' instead of
apr_snprintf(..., "%02X" for each character. Output is the same. I have left the uppercase conversion, because I'm unsure if it is usefull or not. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1429559 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/ssl')
-rw-r--r--modules/ssl/ssl_util_ssl.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/modules/ssl/ssl_util_ssl.c b/modules/ssl/ssl_util_ssl.c
index 0785a576a1..c0096011c1 100644
--- a/modules/ssl/ssl_util_ssl.c
+++ b/modules/ssl/ssl_util_ssl.c
@@ -555,14 +555,17 @@ int SSL_CTX_use_certificate_chain(
char *SSL_SESSION_id2sz(unsigned char *id, int idlen,
char *str, int strsize)
{
- char *cp;
- int n;
+ if (idlen > SSL_MAX_SSL_SESSION_ID_LENGTH)
+ idlen = SSL_MAX_SSL_SESSION_ID_LENGTH;
+
+ /* We must ensure not to process more than what would fit in the
+ * destination buffer, including terminating NULL */
+ if (idlen > (strsize-1) / 2)
+ idlen = (strsize-1) / 2;
+
+ ap_bin2hex(id, idlen, str);
+ /* XXX: is this ap_str_toupper() necessary ? */
+ ap_str_toupper(str);
- cp = str;
- for (n = 0; n < idlen && n < SSL_MAX_SSL_SESSION_ID_LENGTH; n++) {
- apr_snprintf(cp, strsize - (cp-str), "%02X", id[n]);
- cp += 2;
- }
- *cp = NUL;
return str;
}