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

Make URL normalization safe #2695

Closed
Closed

Description

@tmcw

https://github.com/mapbox/mapbox-gl-native/blob/master/src/mbgl/util/mapbox.cpp#L87-L90

All of the normalization methods in this file assume that pathname has the right arity before using parts of it constructing URLs. When it doesn't - when it's just a style id or something, or missing some chunk - then concatenating the strings leads to a malloc, as seen in http://stackoverflow.com/questions/33227894/how-do-i-show-a-map-from-a-mapbox-project-with-the-mapbox-ios-sdk

The methods should assert the correct arity before proceeding.

Activity

  1. ljbade commented on Oct 22, 2015

    @ljbade
    Contributor

    @tmcw Yeah can we support this, I have tried to do it before on Java but was getting too complicated.

    Also we need a way to return an error back via JNI instead of normal C++ exception which just crashes the app on Java with no way to provide a useful error message to developers.

    Something like a isStyleUrlValid() function, or even some sort of bool or otherwise return from setStyleUrl(). Then we can throw on Java a helpfully named exception like InvalidStyleUrlException

    Another alternative is to generate a failedToLoad event (see #630 and #2263)

    @jfirebaugh what is your preference about sending the URL validation result back to Java?

  2. ljbade commented on Oct 22, 2015

    @ljbade
    Contributor
  3. added this to the android-v2.2.0 milestone on Oct 22, 2015
  4. jfirebaugh commented on Oct 22, 2015

    @jfirebaugh
    Contributor

    The first step is to make this not crash: if the result from getMapboxURLPathname() has less segments than expected, return url.

    Later we can add validation and diagnostic messages. These should probably happen at style parse time, with the rest of the validations.

  5. 1ec5 commented on Oct 26, 2015

    @1ec5
    Contributor

    → #2804

  6. added a commit that references this issue on Nov 6, 2015
    334d27e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions