Fossil SCM

checkin/e4cdf03b4547c838ec0ea417bc12ac1505cf7c670216e59da1109c34ad5155ae

2 weeks, 2 days ago by dmestas

Heap buffer overflow in blob_delta_create()

blob_delta_create() gave delta_create() an output buffer 16 bytes larger than the target. delta_create() documents a need for 60.

A delta whose target shares nothing with its source is one literal: SIZE\nSIZE:, the target, then CHECKSUM;. Once the target reaches 2^24 bytes, SIZE takes five base-64 digits and the overhead is up to 19 bytes. The last one or two bytes landed past the end of the buffer.

It is reached from commit (content_deltify), sync (send_delta_native), stash and bundle export, whenever a file of 16 MB or more is deltified against content it has nothing in common with.

The fix allocates 60 extra bytes, as the contract says. The other callers of delta_create() already allocate 70.

To see it, on an ASan build of the parent check-in:

head -c 17000000 /dev/urandom >t
head -c 100 /dev/urandom >s
fossil test-delta-create s t d

Keyboard Shortcuts

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