Skip to content

Commit b1f24e3

Browse files
committed
ext/imap: Add const qualifier for header_injection()
Also reformat long if condition to make it clearer
1 parent b1dd9b8 commit b1f24e3

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ext/imap/php_imap.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3187,21 +3187,25 @@ PHP_FUNCTION(imap_fetch_overview)
31873187
}
31883188
/* }}} */
31893189

3190-
static bool header_injection(zend_string *str, bool adrlist)
3190+
static bool header_injection(const zend_string *str, bool adrlist)
31913191
{
3192-
char *p = ZSTR_VAL(str);
3192+
const char *p = ZSTR_VAL(str);
31933193

31943194
while ((p = strpbrk(p, "\r\n")) != NULL) {
3195-
if (!(p[0] == '\r' && p[1] == '\n')
3196-
/* adrlists do not support folding, but swallow trailing line breaks */
3197-
&& !((adrlist && p[1] == '\0')
3198-
/* other headers support folding */
3199-
|| (!adrlist && (p[1] == ' ' || p[1] == '\t')))) {
3200-
return 1;
3195+
if (
3196+
!(p[0] == '\r' && p[1] == '\n')
3197+
/* adrlists do not support folding, but swallow trailing line breaks */
3198+
&& !(
3199+
(adrlist && p[1] == '\0')
3200+
/* other headers support folding */
3201+
|| (!adrlist && (p[1] == ' ' || p[1] == '\t'))
3202+
)
3203+
) {
3204+
return true;
32013205
}
32023206
p++;
32033207
}
3204-
return 0;
3208+
return false;
32053209
}
32063210

32073211
/* {{{ Create a MIME message based on given envelope and body sections */

0 commit comments

Comments
 (0)