Fossil SCM

checkin/8d9ab429e6a081526fd1d762e12bfbeae24353efbcfb99de9c6077728f7a960e

1 week, 2 days ago by dmestas

Bounds checks in the svndiff0 reader of fossil import --svn

svn_apply_svndiff() in src/import.c applies the deltas of a dump made with svnadmin dump --deltas. It used every offset and length in a delta without checking it, so a malformed delta made the importer read outside its buffers, and one kind wrote past the end of the new file's buffer. This matters to anyone who imports a dump they did not make.

Now every number is read within its section, and every offset and length is checked against the buffer it refers to. 10bdbac2ef adds that a window must make exactly as many bytes as it declares. A malformed delta stops the import with "Invalid svndiff0 format"; sound deltas are applied as before.

Tested with ASan and UBSan on macOS and Linux (x86-64): malformed windows that between them break every check, which read or wrote outside a buffer before, are now refused with no report; sound deltas give the same file as before; and dumps written by Subversion itself (1.15.0 and 1.14.5) import byte for byte. The tests are in a new test/import.test, which will come with the test-suite work. Not run on Windows.

Left as it was: as I read the format, a copy from the target counts from the start of the current window, while Fossil counts from the start of the new file. Subversion wrote no such copy in any delta I made.

Keyboard Shortcuts

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