]> granicus.if.org Git - apache/commitdiff
Improve mc_session_id2sz as suggested by RĂ¼diger.
authorPaul Querna <pquerna@apache.org>
Wed, 13 Jun 2007 02:18:59 +0000 (02:18 +0000)
committerPaul Querna <pquerna@apache.org>
Wed, 13 Jun 2007 02:18:59 +0000 (02:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@546708 13f79535-47bb-0310-9956-ffa450edef68

modules/ssl/ssl_scache_memcache.c

index d7235d87eff234a1240e633010bd7213a162e35b..62ceaa38c243f0304caaa60f2586fac24e3516ba 100644 (file)
@@ -168,13 +168,16 @@ static char *mc_session_id2sz(unsigned char *id, int idlen,
 {
     char *cp;
     int n;
+    int maxlen = (strsize - MC_TAG_LEN)/2;
+
     cp = apr_cpystrn(str, MC_TAG, MC_TAG_LEN);
-    for (n = 0; n < idlen && n < (MC_KEY_LEN - MC_TAG_LEN); n++) {
-        apr_snprintf(cp, strsize - (cp-str), "%02X", id[n]);
+    for (n = 0; n < idlen && n < maxlen; n++) {
+        apr_snprintf(cp, 2, "%02X", id[n]);
         cp += 2;
     }
+
     *cp = '\0';
+
     return str;
 }