Dear Maintainer,
apt_pkg.config.value_list() segfaults when an apt configuration list
contains a non-ASCII byte.
Minimal reproducer:
import apt_pkg
import tempfile
apt_pkg.init_config()
with tempfile.NamedTemporaryFile("wb", delete=False) as f:
f.write(b'Test {\x80};\n')
p = f.name
apt_pkg.read_config_file(apt_pkg.config, p)
apt_pkg.config.value_list(“Test")
Actual result:
Segmentation fault inside apt_pkg.cpython-313-aarch64-linux-gnu.so
Expected result:
The malformed configuration should be rejected with an exception or
parse error instead of crashing the Python interpreter.
I originally hit this through unattended-upgrades after an invalid byte
was accidentally inserted in /etc/apt/apt.conf.d/50unattended-upgrades.
I reduced it to the python3-apt reproducer above.
This appears related to #995118, but affects
apt_pkg.config.value_list() rather than apt_pkg.TagSection.keys().
I also reproduced the issue on x86, so it does not appear to be
arm64-specific.