Fossil SCM

checkin/7a8975dd84db67546bca0be02f33e2b045090182488e2c21b88a41b6ccff83d6

5 days, 14 hours ago by dmestas

Overread and overflow in manifest_reparent_checkin()

manifest_reparent_checkin() in src/manifest.c splits the value of a parent tag into check-in hashes. It began scanning each hash 40 bytes in, without knowing the hash was that long, and stored each hash before checking the count against the size of its array. A malformed value read past the end of its copy, or wrote a pointer one entry past the end of the array. The code runs for a tag artifact that arrives by sync from a user who may push, and again on every rebuild of a repository that holds one.

The fix measures each hash from its start, checks the count before storing a hash, and stores only a value that is a valid hash.

Reviewed with 31 chosen and 300 random values in a harness that runs the old and the new loop: the old one overflowed on 32 of them and the new one on none, and every other value gives the same result in both. Tested with ASan and UBSan on macOS. The tests are in test/crosslink.test, which will come with the test-suite work. Not run on Linux or Windows.

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button