This is an archive of the discontinued Mercurial Phabricator instance.

xdiff: replace {unsigned ,}long with {u,}int64_t
ClosedPublic

Authored by quark on Mar 9 2018, 5:54 PM.

Details

Summary

MSVC treats "long" as 4-byte. That could cause overflows since the xdiff
code uses "long" in places where "size_t" or "ssize_t" should be used.
Let's use explicit 8 byte integers to avoid

FWIW git avoids that overflow by limiting diff size to 1GB [1]. After
examining the code, I think the remaining risk (the use of "int") is low
since "int" is only used for return values and hash table size. Although a
wrong hash table size would not affect the correctness of the code, but that
could make the code extremely slow. The next patch will change hash table
size to 8-byte integer so the 1GB limit is unlikely needed.

This patch was done by using sed.

[1]: https://github.com/git/git/commit/dcd1742e56ebb944c4ff62346da4548e1e3be67

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

quark created this revision.Mar 9 2018, 5:54 PM
indygreg accepted this revision.Mar 9 2018, 6:19 PM
This revision is now accepted and ready to land.Mar 9 2018, 6:19 PM
This revision was automatically updated to reflect the committed changes.