Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

[WIP] detect overlong/surrogate utf8 #430

Merged
merged 6 commits into from
Aug 16, 2018
Merged

[WIP] detect overlong/surrogate utf8 #430

merged 6 commits into from
Aug 16, 2018

Conversation

buixor
Copy link
Contributor

@buixor buixor commented Jul 19, 2018

Add a generic internal rule associated to detection of overlong/surrogate utf8


/* unescape routine :
- returns number of nullbytes present
- returns -1 if overlong utf8 sequence
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this comment wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% :D

if (ngx_utf8_check(name) != NULL) {
ngx_http_apply_rulematch_v_n(&nx_int__bad_utf8, ctx, req, NULL, NULL, zone, 1, 1);
return (0);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep :)

/* 110XXXXx 10xxxxxx */
if ((s[1] & 0xc0) != 0x80 ||
(s[0] & 0xfe) == 0xc0) /* overlong? */
return s;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add braces {} on that else if

(s[0] == 0xf0 && (s[1] & 0xf0) == 0x80) || /* overlong? */
(s[0] == 0xf4 && s[1] > 0x8f) || s[0] > 0xf4) /* > U+10FFFF? */
return s;
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add braces {} on that else

else
s += 4;
}
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add braces {} on that else



/*
unescape routine :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you return two values in a int ;)

@nbs-system nbs-system deleted a comment from jvoisin Jul 24, 2018
@buixor buixor merged commit 828462c into master Aug 16, 2018
@jvoisin jvoisin deleted the utf8_overlong branch August 19, 2018 14:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants