You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2017/01/09 22:08:02 UTC

svn commit: r1778067 - in /httpd/httpd/trunk/modules: aaa/mod_authnz_fcgi.c aaa/mod_authnz_ldap.c http2/h2_config.c ldap/util_ldap_cache_mgr.c loggers/mod_log_config.c lua/lua_dbd.c lua/lua_request.c proxy/mod_proxy_balancer.c

Author: jim
Date: Mon Jan  9 22:08:01 2017
New Revision: 1778067

URL: http://svn.apache.org/viewvc?rev=1778067&view=rev
Log:
https://bz.apache.org/bugzilla/show_bug.cgi?id=58855

Optimize check for empty strings

Modified:
    httpd/httpd/trunk/modules/aaa/mod_authnz_fcgi.c
    httpd/httpd/trunk/modules/aaa/mod_authnz_ldap.c
    httpd/httpd/trunk/modules/http2/h2_config.c
    httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c
    httpd/httpd/trunk/modules/loggers/mod_log_config.c
    httpd/httpd/trunk/modules/lua/lua_dbd.c
    httpd/httpd/trunk/modules/lua/lua_request.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/trunk/modules/aaa/mod_authnz_fcgi.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authnz_fcgi.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authnz_fcgi.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_authnz_fcgi.c Mon Jan  9 22:08:01 2017
@@ -855,7 +855,7 @@ static int fcgi_check_authn(request_rec
             const char *err;
             const char *user = ap_expr_str_exec(r, dconf->user_expr,
                                                 &err);
-            if (user && strlen(user)) {
+            if (user && *user) {
                 r->user = apr_pstrdup(r->pool, user);
                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                               APLOGNO(02519) "%s: Setting user to '%s'",

Modified: httpd/httpd/trunk/modules/aaa/mod_authnz_ldap.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authnz_ldap.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authnz_ldap.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_authnz_ldap.c Mon Jan  9 22:08:01 2017
@@ -748,13 +748,13 @@ static authz_status ldapuser_check_autho
      */
 
 
-    if (!strlen(r->user)) {
+    if (!*r->user) {
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01699)
             "ldap authorize: Userid is blank, AuthType=%s",
             r->ap_auth_type);
     }
 
-    if (req->dn == NULL || strlen(req->dn) == 0) {
+    if (req->dn == NULL || !*req->dn) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01702)
                       "auth_ldap authorize: require user: user's DN has not "
                       "been defined; failing authorization");
@@ -910,7 +910,7 @@ static authz_status ldapgroup_check_auth
      * and populated with the userid and DN of the account in LDAP
      */
 
-    if (!strlen(r->user)) {
+    if (!*r->user) {
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01709)
             "ldap authorize: Userid is blank, AuthType=%s",
             r->ap_auth_type);
@@ -920,7 +920,7 @@ static authz_status ldapgroup_check_auth
     ent = (struct mod_auth_ldap_groupattr_entry_t *) sec->groupattr->elts;
 
     if (sec->group_attrib_is_dn) {
-        if (req->dn == NULL || strlen(req->dn) == 0) {
+        if (req->dn == NULL || !*req->dn) {
             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01712)
                           "auth_ldap authorize: require group: user's DN has "
                           "not been defined; failing authorization for user %s",
@@ -929,7 +929,7 @@ static authz_status ldapgroup_check_auth
         }
     }
     else {
-        if (req->user == NULL || strlen(req->user) == 0) {
+        if (req->user == NULL || !*req->user) {
             /* We weren't called in the authentication phase, so we didn't have a
              * chance to set the user field. Do so now. */
             req->user = r->user;
@@ -1063,7 +1063,7 @@ static authz_status ldapdn_check_authori
      * and populated with the userid and DN of the account in LDAP
      */
 
-    if (!strlen(r->user)) {
+    if (!*r->user) {
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01722)
             "ldap authorize: Userid is blank, AuthType=%s",
             r->ap_auth_type);
@@ -1091,7 +1091,7 @@ static authz_status ldapdn_check_authori
 
     t = require;
 
-    if (req->dn == NULL || strlen(req->dn) == 0) {
+    if (req->dn == NULL || !*req->dn) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01725)
                       "auth_ldap authorize: require dn: user's DN has not "
                       "been defined; failing authorization");
@@ -1163,7 +1163,7 @@ static authz_status ldapattribute_check_
      * and populated with the userid and DN of the account in LDAP
      */
 
-    if (!strlen(r->user)) {
+    if (!*r->user) {
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01730)
             "ldap authorize: Userid is blank, AuthType=%s",
             r->ap_auth_type);
@@ -1181,7 +1181,7 @@ static authz_status ldapattribute_check_
         ldc = get_connection_for_authz(r, LDAP_COMPARE);
     }
 
-    if (req->dn == NULL || strlen(req->dn) == 0) {
+    if (req->dn == NULL || !*req->dn) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01733)
                       "auth_ldap authorize: require ldap-attribute: user's DN "
                       "has not been defined; failing authorization");
@@ -1272,7 +1272,7 @@ static authz_status ldapfilter_check_aut
      * and populated with the userid and DN of the account in LDAP
      */
 
-    if (!strlen(r->user)) {
+    if (!*r->user) {
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01739)
             "ldap authorize: Userid is blank, AuthType=%s",
             r->ap_auth_type);
@@ -1290,7 +1290,7 @@ static authz_status ldapfilter_check_aut
         ldc = get_connection_for_authz(r, LDAP_SEARCH);
     }
 
-    if (req->dn == NULL || strlen(req->dn) == 0) {
+    if (req->dn == NULL || !*req->dn) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01742)
                       "auth_ldap authorize: require ldap-filter: user's DN "
                       "has not been defined; failing authorization");

Modified: httpd/httpd/trunk/modules/http2/h2_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_config.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_config.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_config.c Mon Jan  9 22:08:01 2017
@@ -309,7 +309,7 @@ static const char *h2_conf_set_stream_ma
 static const char *h2_add_alt_svc(cmd_parms *parms,
                                   void *arg, const char *value)
 {
-    if (value && strlen(value)) {
+    if (value && *value) {
         h2_config *cfg = (h2_config *)h2_config_sget(parms->server);
         h2_alt_svc *as = h2_alt_svc_parse(value, parms->pool);
         if (!as) {
@@ -407,7 +407,7 @@ static const char *h2_conf_add_push_prio
     h2_priority *priority;
     int weight;
     
-    if (!strlen(ctype)) {
+    if (!*ctype) {
         return "1st argument must be a mime-type, like 'text/css' or '*'";
     }
     

Modified: httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c (original)
+++ httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c Mon Jan  9 22:08:01 2017
@@ -674,7 +674,7 @@ char *util_ald_cache_display(request_rec
         return NULL;
     }
 
-    if (r->args && strlen(r->args)) {
+    if (r->args && *r->args) {
         char cachetype[5], lint[2];
         unsigned int id, off;
         char date_str[APR_CTIME_LEN];

Modified: httpd/httpd/trunk/modules/loggers/mod_log_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/loggers/mod_log_config.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_log_config.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_log_config.c Mon Jan  9 22:08:01 2017
@@ -377,7 +377,7 @@ static const char *log_remote_user(reque
     if (rvalue == NULL) {
         rvalue = "-";
     }
-    else if (strlen(rvalue) == 0) {
+    else if (!*rvalue) {
         rvalue = "\"\"";
     }
     else {

Modified: httpd/httpd/trunk/modules/lua/lua_dbd.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_dbd.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_dbd.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_dbd.c Mon Jan  9 22:08:01 2017
@@ -782,7 +782,7 @@ int lua_db_acquire(lua_State *L)
                 arguments = lua_tostring(L, 3);
                 lua_settop(L, 0);
                 
-                if (strlen(arguments)) {
+                if (*arguments) {
                     rc = apr_dbd_open_ex(dbdhandle->driver, pool, 
                             arguments, &dbdhandle->handle, &error);
                     if (rc == APR_SUCCESS) {

Modified: httpd/httpd/trunk/modules/lua/lua_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_request.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_request.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_request.c Mon Jan  9 22:08:01 2017
@@ -382,7 +382,7 @@ static int req_parsebody(lua_State *L)
             sscanf(start + len + 2,
                 "Content-Disposition: form-data; name=\"%255[^\"]\"; filename=\"%255[^\"]\"",
                 key, filename);
-            if (strlen(key)) {
+            if (*key) {
                 req_aprtable2luatable_cb_len(L, key, buffer, vlen);
             }
         }
@@ -2110,8 +2110,8 @@ static int lua_set_cookie(lua_State *L)
             secure ? "Secure;" : "", 
             expires ? strexpires : "", 
             httponly ? "HttpOnly;" : "", 
-            strlen(strdomain) ? strdomain : "", 
-            strlen(strpath) ? strpath : "");
+            *strdomain ? strdomain : "", 
+            *strpath ? strpath : "");
     
     apr_table_add(r->err_headers_out, "Set-Cookie", out);
     return 0;

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=1778067&r1=1778066&r2=1778067&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Mon Jan  9 22:08:01 2017
@@ -1100,13 +1100,13 @@ static int balancer_handler(request_rec
             }
         }
         if ((val = apr_table_get(params, "w_wr"))) {
-            if (strlen(val) && strlen(val) < sizeof(wsel->s->route))
+            if (*val && strlen(val) < sizeof(wsel->s->route))
                 strcpy(wsel->s->route, val);
             else
                 *wsel->s->route = '\0';
         }
         if ((val = apr_table_get(params, "w_rr"))) {
-            if (strlen(val) && strlen(val) < sizeof(wsel->s->redirect))
+            if (*val && strlen(val) < sizeof(wsel->s->redirect))
                 strcpy(wsel->s->redirect, val);
             else
                 *wsel->s->redirect = '\0';
@@ -1165,13 +1165,13 @@ static int balancer_handler(request_rec
             }
         }
         if ((val = apr_table_get(params, "w_hu"))) {
-            if (strlen(val) && strlen(val) < sizeof(wsel->s->hcuri))
+            if (*val && strlen(val) < sizeof(wsel->s->hcuri))
                 strcpy(wsel->s->hcuri, val);
             else
                 *wsel->s->hcuri = '\0';
         }
         if (hc_valid_expr_f && (val = apr_table_get(params, "w_he"))) {
-            if (strlen(val) && hc_valid_expr_f(r, val) && strlen(val) < sizeof(wsel->s->hcexpr))
+            if (*val && hc_valid_expr_f(r, val) && strlen(val) < sizeof(wsel->s->hcexpr))
                 strcpy(wsel->s->hcexpr, val);
             else
                 *wsel->s->hcexpr = '\0';