Skip to content

Commit

Permalink
code: remove side effects from right hand operands of && operator
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Zandbelt <hans.zandbelt@openidc.com>
  • Loading branch information
zandbelt committed Dec 11, 2024
1 parent d1ebde3 commit fdcaf7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 20 additions & 12 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit fdcaf7a

Please sign in to comment.