mapbox / mapbox/vt-pbf

Fix zigzag encoding overflow

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
206
Forks
38
PR merge metrics
No merged PRs in 30d

Description

The current bit-shifting arithmetic for zigzag encoding:

https://github.com/mapbox/vt-pbf/blob/ad933a6492425a0d2eb56744fa1623345dad4cc9/index.js#L125-L127

overflows for `2^31 - 1`, because JavaScript bit-shifting yields signed 32-bit integers: https://www.ecma-international.org/ecma-262/5.1/#sec-11.7.1

This is unlikely to matter in practice, given that tile extents are typically 4096 or 8192

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in index.js at lines 125-127 and inspect the bit-shifting arithmetic used for zigzag encoding. Reproduce the case for 2^31 - 1, then verify that the encoding no longer overflows while preserving the existing behavior for typical tile extents.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.