From 7814fbac67fdce36864a8a1ef987e952f84815ca Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Mon, 11 Mar 2013 16:34:19 +0000 Subject: [PATCH] Merge r1429559, r1451484 from trunk: 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. SSL_SESSION_id2sz is only used for logging, having it in lowercase shouldn't be an issue. Submitted by: jailletc36 Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1455223 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 7 ------- modules/ssl/ssl_util_ssl.c | 17 +++++++++-------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/STATUS b/STATUS index a448bc608e..a2420d875a 100644 --- a/STATUS +++ b/STATUS @@ -116,13 +116,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: 2.4.x patch: trunk patches apply (minus CHANGES for 1448171) 2.4.x cumulative patch: http://people.apache.org/~jailletc36/backport5.patch (minus CHANGES for 1448171) +1: jailletc36, igalic, jim - - * ssl_util_ssl: Speed up logging function by x4 using ap_bin2hex intoduced in 2.4.4 - It will be in lowercase instead of uppercase, but it is only for logging. I don't think this is a real issue. - trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1429559 - http://svn.apache.org/viewvc?view=revision&revision=1451484 - 2.4.x patch: trunk patch applies with offset. - +1: jailletc36, humbedooh, jim PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/ssl/ssl_util_ssl.c b/modules/ssl/ssl_util_ssl.c index 48b561dc3b..b969b41551 100644 --- a/modules/ssl/ssl_util_ssl.c +++ b/modules/ssl/ssl_util_ssl.c @@ -479,14 +479,15 @@ 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); - 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; }