#1126140 apt: libapt-pkg (apt, apt-get) segfaults when Source field is empty in control file

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Arvid Gerstmann
Date:
2026-01-22 09:55:02 UTC
Severity:
normal
#1126140#5
Date:
2026-01-22 09:53:09 UTC
From:
To:
Dear Maintainer,

trying to install a package with an empty 'Source' field in the control
file results in a segfault in `MarkInstall`. This affects `apt`,
`apt-get`, and all consumers of `libapt-pkg` (e.g., `PackageKit`).

Example control file:

```
Package: tux-control
Version: 4.9.0.0
Section: base
Priority: optional
Architecture: amd64
Source:
Maintainer: Tux
Description:  Tux based control systems
```

Notice the "empty" 'Source' field. In the original control file that I
discovered this issue in, there is a trailing space after the colon.

This bug is present in the version of libapt-pkg used by both bookworm
and trixie.

`DPkg` doens't seem to be affected. Installing a package with an empty
'Source' field works just fine.

Below you'll find a stacktrace from running apt-get under gdb:

Starting program: /usr/bin/apt-get install
./codesys-4.9.0.0/codesyscontrol_linux.deb
/bin/bash: warning: setlocale: LC_ALL: cannot change locale
(en_US.UTF-8)
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/x86_64-linux-gnu/libthread_db.so.1".
[Detaching after fork from child process 3570]
[Detaching after fork from child process 3571]
[Detaching after fork from child process 3572]
Reading package lists... Done
[Detaching after fork from child process 3573]
Building dependency tree... Done
Reading state information... Done
Note, selecting 'codesyscontrol' instead of
'./codesys-4.9.0.0/codesyscontrol_linux.deb'

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7e8b41d in pkgDepCache::MarkInstall(pkgCache::PkgIterator
const&, bool, unsigned long, bool, bool) () from
/lib/x86_64-linux-gnu/libapt-pkg.so.6.0
(gdb) bt
#0  0x00007ffff7e8b41d in pkgDepCache::MarkInstall(pkgCache::PkgIterator
const&, bool, unsigned long, bool, bool) () from
/lib/x86_64-linux-gnu/libapt-pkg.so.6.0
#1  0x00007ffff7f7055f in ?? () from
/lib/x86_64-linux-gnu/libapt-private.so.0.0
#2  0x00007ffff7f78360 in ?? () from
/lib/x86_64-linux-gnu/libapt-private.so.0.0
#3  0x00007ffff7f78ce1 in DoInstall(CommandLine&) () from
/lib/x86_64-linux-gnu/libapt-private.so.0.0
#4  0x00007ffff7e15097 in CommandLine::DispatchArg(CommandLine::Dispatch
const*, bool) () from /lib/x86_64-linux-gnu/libapt-pkg.so.6.0
#5  0x00007ffff7f6353e in DispatchCommandLine(CommandLine&,
std::vector<CommandLine::Dispatch, std::allocator<CommandLine::Dispatch>
#6  0x0000555555558a33 in ?? ()
#7  0x00007ffff784524a in __libc_start_call_main
(main=main@entry=0x5555555589a0, argc=argc@entry=3,
argv=argv@entry=0x7fffffffe558) at
../sysdeps/nptl/libc_start_call_main.h:58
#8  0x00007ffff7845305 in __libc_start_main_impl (main=0x5555555589a0,
argc=3, argv=0x7fffffffe558, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffe548) at
../csu/libc-start.c:360
#9  0x0000555555558ad1 in ?? ()