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

Rewrite XS code to fix bug #4

Merged
merged 1 commit into from
Mar 31, 2022
Merged

Conversation

kgoess
Copy link

@kgoess kgoess commented Mar 30, 2022

A review of the XS code in this module raised some questions, so we
rewrote it for clarity and fixed a bug.

  • Re-work to use memchr to find ; and DRY up the case where there's no ;.

  • Add some missing bounds checking on the main parsing, reworking to make
    the checks more obvious.

    • Fixes an issue where string starting with ';' causes a memory access
      before the start of the passed string.
  • Add length checks for '%##' decoding

    • Fixes potential accesses past the end of the key/value
  • Fix issue with quoted value handling

    • A value of a single quote would cause a negative value to be passed
      to svGROW().

Some performance analysis for a typical cookie:

  • pure-perl 111k/s
  • original XS 785k/s
  • this new XS 918k/s.

A review of the XS code in this module raised some questions, so we
rewrote it for clarity and fixed a bug.

 - Re-work to use memchr to find ; and DRY up the case where there's no ;.

 - Add some missing bounds checking on the main parsing, reworking to make
   the checks more obvious.
     - Fixes an issue where string starting with ';' causes a memory access
       before the start of the passed string.

 - Add length checks for '%##' decoding
     - Fixes potential accesses past the end of the key/value

 - Fix issue with quoted value handling
     - A value of a single quote would cause a negative value to be passed
       to svGROW().
@kazeburo kazeburo merged commit 9fe7535 into kazeburo:master Mar 31, 2022
kazeburo added a commit that referenced this pull request Mar 31, 2022
Changelog diff is:

diff --git a/Changes b/Changes
index 9986710..d414be5 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,10 @@ Revision history for Perl extension Cookie-Baker-XS
 
 {{$NEXT}}
 
+0.12 2022-03-31T04:24:47Z
+
+  - Rewrite XS code to fix bug #4. Thank youk goess.
+
 0.11 2019-06-07T06:30:07Z
 
   - just bump up version. PP requires newer version number
@kazeburo
Copy link
Owner

Great job! Thank you!
Released v0.12.

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