Skip to content

curlx_strtoofft() doesn't fully protect against null "str" argument #1950

Closed

Description

@bnason-nf

With curl 7.46.0, in curlx_strtoofft(), there is a check for a null "str" argument, but the remaining lines of the function don't guard against null. Currently, it it would cause a null pointer dereference if str were ever null.

So, either the first condition in this while loop is unnecessary if str can never be null:

while(str && *str && ISSPACE(*str))

Or the remaining code should be changed to handle a null str argument (maybe just an early out at the top of the function would be simplest).

Activity

  1. bnason-nf commented on Oct 5, 2017

    @bnason-nf
    ContributorAuthor

    By the way I'm happy to provide a patch and pull request if there is a preference for which way to go with this.

  2. bagder commented on Oct 5, 2017

    @bagder
    Member

    First, 7.46.0 is really old so we don't really care much how we did back then. But...

    The code still has a similar construct. We just don't support a NULL pointer in the first argument so the check for that being non-NULL is completely superfluous. We should perhaps instead make than an assert.

  3. jay commented on Oct 5, 2017

    @jay
    Member

    I think he means 7.56, I can't find that code in 7.46. I agree it should be removed. It is the same as if you call strtoll or _strtoi64 with null for the first argument.

  4. bagder commented on Oct 5, 2017

    @bagder
    Member

    ah, makes sense. Yes please @bnason-nf, a PR would be nice!

  5. bnason-nf commented on Oct 5, 2017

    @bnason-nf
    ContributorAuthor

    Yes sorry, 7.46.0 is a typo, I meant the latest 7.56.0. I will put together a PR.

  6. added a commit that references this issue on Oct 5, 2017
    849a67c
  7. locked as resolved and limited conversation to collaborators on May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions