Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up attribute handling with fancy quotes #1838

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

eboasson
Copy link
Contributor

This

   if (n == 0xe2 && (peek_chars (st, "\xe2\x80\x9c", 0) || peek_chars (st, "\xe2\x80\x98", 0))) {
     /* allow fancy unicode quotes (U+201c .. U+201d and U+2018 ... U+2019) in
        UTF-8 representation because email clients like to rewrite plain ones,
        and this has caused people trouble several times already */
     (void) next_char (st); (void) next_char (st);
     const unsigned char c = (unsigned char) next_char (st);
     const unsigned char endm[4] = { 0xe2, 0x80, (unsigned char) (c + 1), 0 };
     tok = next_token_string (st, payload, (const char *) endm);
   }

nice little hack caused so many calls to strlen en memcmp that it timed out on OSS-Fuzz. It doesn't seem like an issue for actual configurations and it does terminate in a few seconds on a normal machine, but OSS-Fuzz also matters. Fortunately, this case can be fixed rather easily.

This

   if (n == 0xe2 && (peek_chars (st, "\xe2\x80\x9c", 0) || peek_chars (st, "\xe2\x80\x98", 0))) {
     /* allow fancy unicode quotes (U+201c .. U+201d and U+2018 ... U+2019) in
        UTF-8 representation because email clients like to rewrite plain ones,
        and this has caused people trouble several times already */
     (void) next_char (st); (void) next_char (st);
     const unsigned char c = (unsigned char) next_char (st);
     const unsigned char endm[4] = { 0xe2, 0x80, (unsigned char) (c + 1), 0 };
     tok = next_token_string (st, payload, (const char *) endm);
   }

nice little hack caused so many calls to strlen en memcmp that it timed
out on OSS-Fuzz.  It doesn't seem like an issue for actual
configurations and it does terminate in a few seconds on a normal
machine, but OSS-Fuzz also matters.  Fortunately, this case can be fixed
rather easily.

Signed-off-by: Erik Boasson <[email protected]>
@eboasson eboasson merged commit 5d5eb59 into eclipse-cyclonedds:master Sep 26, 2023
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants