TurboPFor: ensure input (!) is padded, too
commitc10cc77a4b3aa84957341149d4630fd7dff387ea
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 16 Jan 2024 16:57:56 +0000 (16 17:57 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 16 Jan 2024 17:01:11 +0000 (16 18:01 +0100)
tree1ebe268d546b50605e52ff8588d28fc4e77ca84f
parentef1baf9de0fb4c9cfc92d9fd722197bb984654b1
TurboPFor: ensure input (!) is padded, too

We already ensured the output buffers we pass to TurboPFor are padded,
but it turns out that TurboPFor also reads past its input buffer!
(At least in the version we’re currently using.)

This manifested in crashes when merging multiple index files together,
and only first occurred starting a few weeks ago, presumably because a new
package entered the Debian archive that happens to trigger the bug.

Reading past the number of input bytes in the input buffer is not just an
invalid memory access, but a Segmentation Violation because we mmap
the input files.

fixes https://github.com/Debian/dcs/issues/123
internal/turbopfor/turbopfor.go