]> granicus.if.org Git - apache/commitdiff
Don't return a pointer to a stack variable
authorStefan Fritsch <sf@apache.org>
Wed, 19 Oct 2011 22:38:18 +0000 (22:38 +0000)
committerStefan Fritsch <sf@apache.org>
Wed, 19 Oct 2011 22:38:18 +0000 (22:38 +0000)
Found by cppcheck

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1186543 13f79535-47bb-0310-9956-ffa450edef68

modules/aaa/mod_authn_socache.c

index 60a7c7aaa3fc167b490d15c21e0660b49270d216..bfe4c7bf336e7c8922c0f068fdb9195337357bad 100644 (file)
@@ -399,7 +399,6 @@ static authn_status get_realm_hash(request_rec *r, const char *user,
         /* OK, we got a value */
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                       "Authn cache: found credentials for %s", user);
-        val[vallen] = 0;
     }
     else {
         /* error: give up and pass the buck */
@@ -408,7 +407,7 @@ static authn_status get_realm_hash(request_rec *r, const char *user,
                       "Error accessing authentication cache");
         return AUTH_USER_NOT_FOUND;
     }
-    *rethash = (char*)val;
+    *rethash = apr_pstrmemdup(r->pool, (char *)val, vallen);
 
     return AUTH_USER_FOUND;
 }