diff --git a/ChangeLog b/ChangeLog index b07bf002..8edfdf12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ - code: loop over authz arrays with index instead of pointer - code: avoid embedding defines in macro arguments - code: avoid cast warnings +- code: add comment to empty functions +- code: remove any side effects from right hand operands of logical && operator 12/10/2024 - github: add SonarQube analysis to Github workflows diff --git a/src/util.c b/src/util.c index 533186a5..9f3af4dc 100644 --- a/src/util.c +++ b/src/util.c @@ -1209,7 +1209,10 @@ apr_byte_t oidc_util_read_form_encoded_params(request_rec *r, apr_table_t *table const char *val = NULL; const char *p = data; - while (p && *p && (val = ap_getword(r->pool, &p, OIDC_CHAR_AMP))) { + while ((p) && (*p)) { + val = ap_getword(r->pool, &p, OIDC_CHAR_AMP); + if (val == NULL) + break; key = ap_getword(r->pool, &val, OIDC_CHAR_EQUAL); key = oidc_http_url_decode(r, key); val = oidc_http_url_decode(r, val); @@ -1646,7 +1649,10 @@ apr_hash_t *oidc_util_spaced_string_to_hashtable(apr_pool_t *pool, const char *s char *val; const char *data = apr_pstrdup(pool, str); apr_hash_t *result = apr_hash_make(pool); - while (*data && (val = ap_getword_white(pool, &data))) { + while ((data) && (*data)) { + val = ap_getword_white(pool, &data); + if (val == NULL) + break; apr_hash_set(result, val, APR_HASH_KEY_STRING, val); } return result; @@ -1787,16 +1793,18 @@ apr_byte_t oidc_util_json_merge(request_rec *r, json_t *src, json_t *dst) { * add query encoded parameters to a table */ void oidc_util_table_add_query_encoded_params(apr_pool_t *pool, apr_table_t *table, const char *params) { - if (params != NULL) { - char *key = NULL; - const char *val = NULL; - const char *p = params; - while (*p && (val = ap_getword(pool, &p, OIDC_CHAR_AMP))) { - key = ap_getword(pool, &val, OIDC_CHAR_EQUAL); - ap_unescape_url((char *)key); - ap_unescape_url((char *)val); - apr_table_add(table, key, val); - } + char *key = NULL, *value = NULL; + const char *v = NULL; + const char *p = params; + while ((p) && (*p)) { + v = ap_getword(pool, &p, OIDC_CHAR_AMP); + if (v == NULL) + break; + key = apr_pstrdup(pool, ap_getword(pool, &v, OIDC_CHAR_EQUAL)); + ap_unescape_url(key); + value = apr_pstrdup(pool, v); + ap_unescape_url(value); + apr_table_addn(table, key, value); } }