Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

the function htparser_get_strerror may have a out-of-bounds read #72

Closed
linimbus opened this issue Jan 9, 2018 · 3 comments
Closed

Comments

@linimbus
Copy link

linimbus commented Jan 9, 2018

Details

Steps or code to reproduce the problem.

  1. The Array of string pointers errstr_map only have 13 item

  2. But. The Enum type htpparse_error had defined 14 item

  3. This code if (e > (htparse_error_generic + 1)) may cause value e large than that array errstr_map size.

Example code (if applicable)

const char * htparser_get_strerror(htparser * p)
{
    htpparse_error e = htparser_get_error(p);

    if (e > (htparse_error_generic + 1))
    {
        return "htparse_no_such_error";
    }

    return errstr_map[e];
}

Version

latest

NathanFrench added a commit that referenced this issue Jan 9, 2018
While the API was never effected by this, I guess a user who had set
their own parser error could have triggered this read. But alas, a bug
is a bug.

We don't look for error + 1 in the error string table, we just look for
error > last_enum.
@NathanFrench
Copy link
Collaborator

I would love to know how someone could have triggered this, since that structure is never made public, thus it was never abused; but a bug is a bug, and I fixed it up here 75574ba

Will merge in a bit.

NathanFrench added a commit that referenced this issue Jan 9, 2018
[#72] Fix for oob read from htparser_get_strerror
@NathanFrench
Copy link
Collaborator

All good - thanks again! You're my human static analyzer!

@linimbus
Copy link
Author

I am happy to contribute to this project!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants