Skip to content

Commit fdcaf7a

Browse files
committed
code: remove side effects from right hand operands of && operator
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent d1ebde3 commit fdcaf7a

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
- code: loop over authz arrays with index instead of pointer
33
- code: avoid embedding defines in macro arguments
44
- code: avoid cast warnings
5+
- code: add comment to empty functions
6+
- code: remove any side effects from right hand operands of logical && operator
57

68
12/10/2024
79
- github: add SonarQube analysis to Github workflows

src/util.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,10 @@ apr_byte_t oidc_util_read_form_encoded_params(request_rec *r, apr_table_t *table
12091209
const char *val = NULL;
12101210
const char *p = data;
12111211

1212-
while (p && *p && (val = ap_getword(r->pool, &p, OIDC_CHAR_AMP))) {
1212+
while ((p) && (*p)) {
1213+
val = ap_getword(r->pool, &p, OIDC_CHAR_AMP);
1214+
if (val == NULL)
1215+
break;
12131216
key = ap_getword(r->pool, &val, OIDC_CHAR_EQUAL);
12141217
key = oidc_http_url_decode(r, key);
12151218
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
16461649
char *val;
16471650
const char *data = apr_pstrdup(pool, str);
16481651
apr_hash_t *result = apr_hash_make(pool);
1649-
while (*data && (val = ap_getword_white(pool, &data))) {
1652+
while ((data) && (*data)) {
1653+
val = ap_getword_white(pool, &data);
1654+
if (val == NULL)
1655+
break;
16501656
apr_hash_set(result, val, APR_HASH_KEY_STRING, val);
16511657
}
16521658
return result;
@@ -1787,16 +1793,18 @@ apr_byte_t oidc_util_json_merge(request_rec *r, json_t *src, json_t *dst) {
17871793
* add query encoded parameters to a table
17881794
*/
17891795
void oidc_util_table_add_query_encoded_params(apr_pool_t *pool, apr_table_t *table, const char *params) {
1790-
if (params != NULL) {
1791-
char *key = NULL;
1792-
const char *val = NULL;
1793-
const char *p = params;
1794-
while (*p && (val = ap_getword(pool, &p, OIDC_CHAR_AMP))) {
1795-
key = ap_getword(pool, &val, OIDC_CHAR_EQUAL);
1796-
ap_unescape_url((char *)key);
1797-
ap_unescape_url((char *)val);
1798-
apr_table_add(table, key, val);
1799-
}
1796+
char *key = NULL, *value = NULL;
1797+
const char *v = NULL;
1798+
const char *p = params;
1799+
while ((p) && (*p)) {
1800+
v = ap_getword(pool, &p, OIDC_CHAR_AMP);
1801+
if (v == NULL)
1802+
break;
1803+
key = apr_pstrdup(pool, ap_getword(pool, &v, OIDC_CHAR_EQUAL));
1804+
ap_unescape_url(key);
1805+
value = apr_pstrdup(pool, v);
1806+
ap_unescape_url(value);
1807+
apr_table_addn(table, key, value);
18001808
}
18011809
}
18021810

0 commit comments

Comments
 (0)