You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2013/01/06 18:40:13 UTC
svn commit: r1429559 - /httpd/httpd/trunk/modules/ssl/ssl_util_ssl.c
Author: jailletc36
Date: Sun Jan 6 17:40:13 2013
New Revision: 1429559
URL: http://svn.apache.org/viewvc?rev=1429559&view=rev
Log:
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.
Modified:
httpd/httpd/trunk/modules/ssl/ssl_util_ssl.c
Modified: httpd/httpd/trunk/modules/ssl/ssl_util_ssl.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_util_ssl.c?rev=1429559&r1=1429558&r2=1429559&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_util_ssl.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_util_ssl.c Sun Jan 6 17:40:13 2013
@@ -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;
}